Jump to content
  • Advertisement
Sign in to follow this  
Juksosah

I need to animate a character.. help !

This topic is 3796 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm fairly new to game programming and I must animate a character. I''m trying to implement a basic movement like walking but my code ends up a total mess. Problems come from that animation is a sequential thing (ex : walking : move left foot ahead, then move it down, use rigth foot. etc.. etc.. etc..) but the game is a looping thing. Because of this loop I must do something like this :
walk (elapsedTime){

If (left leg < 15.0 degrees and leftRotation not done)
    Rotate left leg * speed * elapsedTime;
else
    leftRotationDone

//Now second part ...
If leftRotationDone

//third part

If ...

}
As you see it's pretty ugly and if the movement is a little complicated I will end up with a ton of if's. Is there something simpler to do ? Like dealing with time (after 1 sec. rotate 15 deg)? Could you clear the shroud in my head ? thanks

Share this post


Link to post
Share on other sites
Advertisement
hey

Usually you visually animate your characters keyframes in a 3d editor, and then export the animation keyframes and such to use in ya game. One such program that is free, and that I recommend is Blender.

For basic forward kinematic skeletal animation you just interpolate between different matrices which represent each bone/joint in a parent/child hierarchy. Each vertex is assigned to one or more bones/joints, along with a weight. The weight idicates how much influence the bone/joint has on the vertex, in the case that it's shared/assigned to more than one bone. So for any vertex, if you sum the total weight of influence of each assigned bone/joint, it should equal 1. BTW, this process is known as Vertex Blending, or Skinning.

I won't bother going any further into this, incase it's not what you are looking for, but I think there are tutorials around which I could probably dig up for you if you like.

Anyhows if you want to keep the animation system you current have, then I suggest you implement some sort of keyframe class/structure, where for each keyframe you indicate the angle, and length (the number of frames). So once you have a set of keyframes you just need to interpolate the angle between the current keyframe and the next. Well I've left out quite a bit of detail here, but hopefully this gives you some ideas.

cya

Share this post


Link to post
Share on other sites
Easiest way to deal with something like this is to use a concept called 'Keyframing'. Basically, a keyframe contains information for what state an object should be in at a current time (This could me position, rotation, scale, or even color information, as well as anything else that's numerical and could be altered at run-time).

Keyframes contain 2 main parts of data, time (Of the keyframe), and the state (Position, rotation, etc). So say at time 0.0, your leg would be in a vertical position, but at time 0.25 (Quarter of a second), the leg would be extended to take a step. In the interim, you can interpolate the values so you can have smooth animation.

Share this post


Link to post
Share on other sites
Thanks for your input guys,


I'll try the 'keyframe' approach, not having enough time to dig Vertex Blending or Skinning.


Questions will arise for sure so stay tuned !

Share this post


Link to post
Share on other sites
Quote:
Original post by Juksosah
I'll try the 'keyframe' approach, not having enough time to dig Vertex Blending or Skinning.

You use them both.

Keyframes say "bone 1 should be at (x,y,z) at time 0, and should be at (a,b,c) at time 15". When you render at frame 11 you interpolate the location between the keyframes and move the bones for your skinned mesh appropriately.

Share this post


Link to post
Share on other sites
Quote:
You use them both.


I did. (I do not use meshes, but simple 2D human with limbs)

The main problem is that I suck in animating things. It looks so robotic.

I just don't know how much time to set (sorry I use time instead of frames) between keyframes, and how much time to hold the keyframe.

I must animate a slow moving human.

It looks like ...

keyframe1-----(long interpolation)-----keyframe2(long pause)----and so on

Visually it looks like a robot and it's not natural at all. Maybe it's a timing issue.

I need some animation tips here !

Share this post


Link to post
Share on other sites
Quote:
Original post by Juksosah
Visually it looks like a robot and it's not natural at all. Maybe it's a timing issue.

I need some animation tips here !


You're not going to get anywhere doing your animation through code (Which I'm assuming you're doing here).

In order to get any sort of natural feel to your animations, you really need to be able to see what you're doing, and that means using a 3D animation program such as 3D Studio Max, Maya or Blender, and then exporting the data from there.

Doing animation from code would be like trying to draw a masterpiece in the dark. With a blindfold. And both eyes removed. Holding the brush in your teeth. While plummeting into a ravine.

Share this post


Link to post
Share on other sites
Quote:
Original post by PlayfulPuppy
Doing animation from code would be like trying to draw a masterpiece in the dark. With a blindfold. And both eyes removed. Holding the brush in your teeth. While plummeting into a ravine.


Not a fan of abstract art then?

Share this post


Link to post
Share on other sites

For my abstract game, yes i'm trying to animate from the code..

The program let me move/rotate each limb seperately so I know what my keyframes are looking visually. Better than nothing.

But i'm not sure if an animation program would tell me how much time to use between keyframes !

Share this post


Link to post
Share on other sites
Oh wait ! I'm replying to myself...

Here are some tips I found for computer animation :

http://www.zayatz.com/text/Common%20Pitfalls.htm

I'm in a world of pain. Good animation needs a lot of work !

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!