Forum rules - please read before posting.

Custom Animation Action Wont leave GamePause Action

Hi,
we have a custom AnimationEngine runing which works with Spine2D.
So far movement works fine. Also animation of npcs and the player.
If we call the character animate action, with a custom animation with the player, he does exactly what he is supposed to. Also if you retrigger the action list over the hotspot, it works fine. But if you move the player and play the animation a second time, it will play the animation, but after the animation has finished, the game stays in gamepause action and you dont get back controll.
Any idea why that might happen?
Or any idea how i might be able to debug it?
How does the action know, when the animation is finished? (i suspect the bug to be there, but i still dont know, why it works the first time.
Pls let me know if you need any scripts from me.
AC version: 1.70.2 -> Unity 2019.3.1f1

Sincerely,
Max

Comments

  • It would be down to the way your custom animation engine script is constructed.

    You're correct in that the Action needs to know that the animation has finished - but this'll only be the case if Wait until finish? is checked.

    For the Character: Animate Action, this check is made in the animation engine's ActionCharAnimRun function.

    This method behaves similarly to Action Run functions (see the ActionTemplate script for comments), in that - if isRunning is set to true - it will keep being called until isRunning is set to false, and it returns 0f. So to end the Action, you just need to call:

    action.isRunning = false;
    return 0f;
    

    The function will need to determine if the animation has finished playing. You can see that the Sprites Unity engine this by reading GetCurrentAnimatorStateInfo on line 432:

    if (character.GetAnimator ().GetCurrentAnimatorStateInfo (action.layerInt).normalizedTime < 0.98f)
    {
        return action.defaultPauseTime;
    }
    else
    {
        action.isRunning = false;
        return 0f;
    }
    

    If your custom engine still relies on an Animator, you may be able to use the same check.

  • thanks a great deal for the in dept explanation. that helped a lot finding the bug, now it runs as expected. (we had a faulty reference to the completion listener, of the custom animation.)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.