Skip to main content
GameDev.net gamedev.net
🔒 Locked

Playing animations based on events/input

Started by sbetchel Feb 7, 2006 at 4:43 PM 0 replies 950+ views
Original Post
sbetchel
sbetchel
Hi all. I was wondering how you would go about playing certain animations (im using skeletal animation, namely brett's skeletal animation tutorial code on rsn.gamdev) according to certain events. For example, while nothing is happening, I just want my character to stand there and play an 'idle' animation. When I press 'W', I want the forward walk animation to play as well as translating the character forward. Basic game stuff. Although I'm new to animation. Firstly, can I store all of these animations with the same model and just reference a 'start keyframe' and an 'end keyframe' to loop/play thru on the specified event? example: if my timeline had every animation for a character, and death animation was keyframe 50 to 111, is something possible such as: if( bPlayerDead ) { Animate(50, 111); // (start frame, end frame) // return to whatever } or do I store a new model for each animation and load them all at startup and just switch between them? Any advice would be helpful, also any tutorials/articles on the matter :) thanks!!
xEricx
xEricx
Hi,

Storing all of your animations within only one file will become a huge mess. As soon as you'll want to add frames to an animation at the beginning of the file, all your ranges will be wrong. Also, there is no need to store the "model" in each of your file, you could have a .mesh and a few .anims that contain only the informations about the bone's position/rotation/scale...

What you should consider is implementing "layers" or "channels" of animation. You could have say, 4 channels, all playing at the same time, played from channel 0 to channel 3. Any animation on a lower channel will be overridden by a higher level channel. This way, you can play a whole body animation on channel 0, like an idle animation, a laughing animation that only affects the upper body on channel 1 and a waving animation that only affects left arm on channel 2. When done properly, this kind of system can become pretty powerful.

You should also implement a way to play an animation in loop or one time only... so setting a looping animation on channel 0 becomes your "idle" animation. A one time animation should "clear" its channel upon completion, so that the lower levels can still affect the bones when its done.

Hope this helps

Eric

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.