Jump to content

Animation syncing problem in 2D


SymboliC

Recommended Posts

Hello all,

Me and a friend of mine are trying to create a game...

I am the graphics guy and creating the animations using Spriter.
He is the developer using Unity enviroment and the assets and sprites that I create.

Here is the scenario for a typical problem...

We have two animations...

Let's say,
One is RUNNING and the other one is FIRE WHILE RUNNING.

When you press the right arrow, the character starts to run (RUNNING) by default... and while running, if you press the fire key, another animation is triggered(FIRE WHILE RUNNING) in which the main character's right arm is risen as if shooting projectiles while running.

The problem is both animations have the equal series of images (8 frames each, typical walk/run cycle) but the enetring and exiting the FIRE WHILE RUNNING animation is timeless, I mean it will eventully occur randomly depending on the interaction of the player.

While transtioining from one animation to another, the legs just scramble... or there seems to be a glitchy skipping because that while FIRE WHILE RUNNING anim is let's say, on the 6th frame, the player stops to fire and therefore, RUNNING animation starts FROM THE FIRST FRAME... skipping the last two frames of FIRE WHILE RUNNING, which causes an absurd skipping in RUN cycle, considering the legs part.

You may suggest to tear apart the body and use same leg sub-animation for both of these two different animations. But this ime another problem similar to the one above comes into play. The anatomic syncing of arms with legs!!!

How do you overcome this problem in UNITY or do we have to do something additional in Spriter-side?
How do you sync the positioning of the legs in both animations so that on entering and exiting of those two animations, the legs are always stay in sync??...

Thanks a lot...

Link to comment
Share on other sites

Would you suggest us to run the both animations at the same time and only swapping the visibilities of animations depending on the firing input so that the legs of both animations always stay synced hence they'll both be on the same "N"th frame therefore sharing the same positioning of the legs?

 

I guess this is the logical solution to it but we couldn't figure out how to do this in Unity enviroment...

Is "layered animation" an answer for this or is it completely another different story?

 

Any help is appreciated.

 

Thanks again...

Link to comment
Share on other sites

Ideally Spriter implementations would be able to keep track of the current time ratio of the playing animation, and when you swap animations you start the new animation at the same time ratio as the previous animation.  I'm not sure Unity lets you do this with animations once they are imported though.  I suggest you look into retrieving current animation time.

 

Cheers,
Mike at  BrashMonkey

Link to comment
Share on other sites

Ideally Spriter implementations would be able to keep track of the current time ratio of the playing animation, and when you swap animations you start the new animation at the same time ratio as the previous animation.  I'm not sure Unity lets you do this with animations once they are imported though.  I suggest you look into retrieving current animation time.

 

Cheers,

Mike at  BrashMonkey

Thanks for the relpy Mike...

However, do you mean "current frame in the timeline" by saying "time ratio" OR do you mean elapsed time calculation for two animations which have different lengths of duration??...

Do you say that you'll be able to continue from the specific time in the second animation where you've left off in the first animation??

I did a heavy search for hours regarding my question and found out that "avatar masks" and "layered animation" seem to do this thing in order to animate the different body parts independently from the remaining parts of the body. A very common example on the web regarding tis is; a character waving his right hand while walking and then sifting to normal walking where legs are in a continuous movement.

the problem is that "avatar masks" in Unity seems to involve 3D characters and enviroment.

Is there any way to simulate this in 2D animations?...

Or if only I understood you correctly and would be able to apply the same thing in Unity... =/

Thanks a lot,

Link to comment
Share on other sites

Hi again SymboliC,

 

If both animations are the same duration then current time ration and current time would be identical... but, if for example you had an 8 key-frame walk animation that was 1000 milliseconds, and a matching 8 frame run animation that was only 600 milliseconds, then you'd need to compare the current time ratio and not current time.

 

 

I'm no Unity expert so I don't know if there's a way to retrieve either, but their certainly should be.

 

A quick Google search found these results.. hopefully one will be useful to you"

 

http://docs.unity3d.com/ScriptReference/AnimationState-time.html

 

http://docs.unity3d.com/ScriptReference/AnimationState.html

 

http://forum.unity3d.com/threads/how-to-get-animations-current-frame.98805/

 

 

 

cheers,
Mike at BrashMonkey

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...