Problem with animations synchronization

0 favourites
  • 13 posts
From the Asset Store
Sync animations, animation frames, mirror state, sounds and anything else using these methods.
  • Hi everyone,

    I just started to implement separated animations for my characters and their weapons, and I’m struggling to synchronize them with precision, even though they have the same number of frames and animation speed.

    Just run this code with the debugger, and when an attack is about to be finished, pause and advance step by step.

    You’ll notice that the weapon will get into idle animation one frame before the knight, even though the sword is dependent on the knight attack animation to be finished to launch its idle animation.

    If I move the action in event 4 to event 2, launching the 2 animations in the same event, the problem is STILL there!

    The only workaround I found for that is to put a wait 0 action at the beginning of event 4, but I’m guessing this is not the proper way to do that kind of things.

    Even weirder is that, even when I put the wait 0 action at the beginning of event 4, the idle animations are not synchronized. The sword is 1 tick earlier. And if I don’t put the wait 0 action at the beginning of event 4, then the sword animation is a huge 2 tick earlier than the knight!

    Am I missing something here?

    Is there a much more consistent way to do that kind of animation synchronization that I am not aware of?

    Thanks for your help!

  • Rable This was the only way I could find to get the animations to consistently sync on every step:

    https://www.dropbox.com/s/po3c2aabf8h6c ... .capx?dl=0

    It still uses a wait 0 seconds to stop the sword idle jumping ahead, so maybe not ideal?

  • mekonbekon

    Thanks a lot for your help. At least it's possible to make it look right.

    However, this is still a workaround in my opinion, and it requires checking the animation frame every tick, which isn't optimal. Is the behavior described above the way it is supposed to be? It looks like a bug to me. Maybe Ashley or another Construct guru can confirm if this is intended or not?

    I just tested the capx in C3 and the result is exactly the same in C3 than in C2.

  • Yeah, checking the animation frame every tick isn't great, but perhaps not such a huge cpu hit - might be worth stress testing.

    I'm guessing that it's something to do with objects only being drawn at the end of the step. Not sure why that would result in the sword switching to idle *before* the knight though.

  • The animation system is actually pretty complicated, and there are sometimes one-tick delays before it starts animations to work around edge cases like changing the animation in an "on animation finished" trigger. You can just force the sword to use the same animation frame as the knight. These events work fine:

    https://www.dropbox.com/s/mfaelh6fz1cgk67/knight-anim-events.png?dl=0

  • Hi Ashley

    That's the same as I had in my demo, except I had to insert a wait 0 seconds between the "Set animation to idle" actions, otherwise at the end of the attack anim the sword idle triggers before the knight idle. You can see this if you step through your example in debug to the end of the attack anim. It's odd that it should do this - why wouldn't both anims change on the same frame given that the actions are on the same trigger?

  • Indeed, I'm afraid the wait 0 seconds is mandatory here. I tried your suggestion Ashley, and the problem is still there.

    From what I can see so far, the cleanest way to do this is this one:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Animation triggers have to delay changing animation by a tick. I can't remember exactly why, I wrote the code years ago. But I think that a 'set animation' can't have effect in the same event as the same object's 'on animation finished' trigger, because if you have two triggers, by the time the second one fires it's not playing the same animation any more, which causes some bug or crash. I don't think there's a better way to work around it. Since the 'sword' object is not the same object as the trigger, it can change animation straight away.

    I guess another workaround would be to use an invisible object to control the animations, and then control both the knight and sword animations from that. Then they both ought to work identically, since neither is involved in the trigger.

  • Thanks for the explanations. It all makes sense and we now know how to work around it efficiently.

  • Hey Rable!

    The only way I managed to get the animations perfectly synchronized was by using an "on frame change" action on the knight to set the animation and frame of the sword. I don't know how processing intensive it would be, but...

    Here's the .capx

  • Thanks for the idea! But the capx doesn't seem to be downloadable with the link you provided. :-/

  • My bad, I thought the files inherited the permissions of the folder, which is shared, in Dropbox (never used it before).

    Try this one

  • brunopalermo

    Nice! I didn't thought about that but it is a much simpler solution.

    Thanks for that!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)