# C++ How to have a good looking character animation?

## Recommended Posts

Posted (edited)

Hello, I'm working on a 2D isometric game, and my character's animation doesn't satisfy me: The character kind of slips on the ground.

The animation looks like this (with this animation file). The code is similar to this:

// Moving character at south east
character.pos.x += 8; // pixels
character.pos.y += 4;
++character.animation.frame;

Do you have any tips to improve it?
Thanks

Edited by Apjue

##### Share on other sites

Analyze the image, determine how far the feet move between consecutive frames (relative to some "root" position, like the center of their head or something). Store that offset with the frame data, move the character only that far each frame.

For the five frames below, I drew a line from the player's nose to the tip of their left (backwards-moving, and therefore "planted" and presumably unmoving foot). In frame #1, it's at +1x from the nose. In frame #2, it's at -9x, and therefore moved -10x. So, when driving the character, the player's sprite should move forward by about +10 pixels. One frames #3 and #4, the toe is at -14x and -19x, so the character should move forward by another +4 and +5 pixels, respectively, before those frames.

Naturally, you'll want to use that as a guideline; the player won't be moving directly east unless they are snapped to the grid, so you'll want to move the player in their precise travel direction vector, normalized and then multiplied by the magnitude measured by this process.

If you're lucky, the person who made the animation used the same animation viewed from varying angles, instead of making eight bespoke animations, and so the magnitude of the foot's movement will be the same in all the rotations. Remember to account for the projection (10px in X is 5px in Y if the projection ratio between X and Y is 2:1).

##### Share on other sites

Professionally-done animations are all using animation tools. You should not hardcode animation deltas in your code. You are already having issues animating one object, what do you think is going to happen when animating hundreds more different types of objects?

##### Share on other sites

Thanks for replying, I understand your solution Wyrframe but it is quite long to hardcode animation deltas, as said alnite

I don't know if the animation was done professionally, I found it for free and no 3D model file was provided, is it the only possible solution?

##### Share on other sites

It's definitely going to work at least.

Basically you want one foot to stick to the ground. As a first guess, I'd say it's the lowest foot, and the "back" one if there is a choice.

Maybe you can write a program that finds that foot in each frame and then compute offsets relative to it. Obviously this is not going to work 100%, at least when changing foot something has to be done (but a simple heuristic may work, eg don't move too much).

A simpler option could be to write a program where you align each frame on top of the previous frame manually, if the computer assists you eg like above, or by extra-polating movement in some way, it may be faster.

## Create an account

Register a new account

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 13
• 18
• 15
• 9
• 9