Smooth transition between 2D animations

Started by
6 comments, last by Wyrframe 15 years, 7 months ago
Imagine a game like Street Fighter - a 2D fighting game with lots of animations. For example purposes: I have a "Stand" animation and I have a "Punch" animation. I want to transition from "Stand" to "Punch". Now when I go from "Stand" to "Punch" the image seems to 'jump' because I display the new animation at the same coordinates as the old image but inside the frame the character is in a different location: STAND FRAME |---| |---| |---| |_X_| PUNCH FRAME |-----| |-----| |-----| |---X-| Notice how when you transition from "Stand" to "Punch" the character's body has 'jumped' to the right when displaying the "Punch" animation. Possible Solutions 1. Make all animation frames for every animation the same size. If all animation frames are the same size the character within the frame can be positioned in the same spot within the frame every time. PROBLEM: Size! Imagine if the character were large - with 20 different animations! Ouch. 2. Track the central location of the character within each frame of animation During the transition between "Stand" and "Punch" I would put the "Punch" central character coordinate on the same screen coordinates as the "Stand" central character coordinate - this would align the two images and remove the 'jump'. PROBLEM: Every frame of every animation needs a central character coordinate Any thoughts for a better solution!?! Thanks!
Advertisement
well the way I solved it for my game is to not draw my bobs from the top-left corner of the image. In stead the "position" of my characters originates from the center-bottom point of the image. So whenever I draw a frame, I offset it like this:

real_x = char_x - (frame_width / 2)
real_y = char_y - frame_height

That works fine for me, if you take care to position your character graphics properly in all the frame images.
gimbal_: This solution is somewhat better than my first possible solution. Each animation can be a different size, but each image needs to begin and end with the character in the center of the frame. Could be size issues if there is a large punch animation to the right because the image would need to be the same distance to the left also. But awesome suggestion! Thanks!
Quote:Original post by brentstrandy
Any thoughts for a better solution!?! Thanks!

I don't know about a better solution, but you've already mentioned the two most common solutions. Your "central character coordinate" system is extremely common and usually known as the image's "origin." It may seem like a lot of work to fine-tune all of those origins, but it's a simple and flexible solution to the problem.
"Your "central character coordinate" system is extremely common and usually known as the image's "origin.""

Really? Well I guess I can use that algorithm. It just didn't seem very solid of an idea to me. Thanks!

You COULD allow your animations to finish before input is taken (otherwise you have games like gunz where you can take a sword out after you shoot a gun) it makes the game look better =/ then its easier

Since ur talking about some game where you punch things:
if you allow players to attack when an animation isnt over, they can spam a key and attack around 10 times in 1 second... which i think you dont want :P

I reccomend you use the origin system the people above were chatting about :P sounds good
Just for thoroughness, if a character is giant, one can use a bone system and connect images end to end. It also makes physics easier to incorporate if that's important.
Your character doesn't need to be large on-screen to use a bone system. See "Soldat"; the character is no taller than 18 to 20 pixels, but uses a full bone and (after death) ragdoll animation system.

'course, the mass values for bullets are a little off, so sometimes you'll get headshotted and your neck will snap, and your head will fly off at the speed of sound. And since the camera follows your head, not your torso, this can produce some trippy deaths.

On the other hand, playing Realistic mode (only enemies in your character's actual field of vision are shown), sneaking up behind someone and decorpitating them with the Ruger 77 hunting rifle can be very rewarding. (and I mean decorpitating; the removal of the corpus, the body. It would be decapitating if the camera and thus 'consciousness' followed the torso, and thus your head is the part apparently removed)
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.

This topic is closed to new replies.

Advertisement