Forum rules - please read before posting.

Can't trigger animation of player via script.

I use AC animations. Animation engine: Sprite Unity

I would like to be able to trigger animations via script. I have tried to play an animation directly via the animator, but it looks like AC overwrites it. I also tried to replace the default idle animation with:

AC.ActionCharAnim.CreateNew_SpritesUnity_SetStandard(KickStarter.player, AC.AnimStandard.Idle, “Buster_explode”);

This does not work although it works via action nodes. What am I doing wrong?

Comments

  • With Sprites Unity, yes - AC will be in control over the animation playback. Unless, that is, you set the character's "charState" to Custom first:

    KickStarter.player.charState = CharState.Custom;
    

    With Sprites Unity Complex, however, animation is entirely transition-based, so it's the better choice if you need to override behaviour through script often.

  • Thanks! That works for me.

  • It looks like this only works if there is a time between set movement false and playing of a custom animation. Anything less than 0.5f sec results in the animation not playing, anything above works.

    KickStarter.stateHandler.SetMovementSystem(false);
    yield return new WaitForSeconds(0.5f);
    KickStarter.player.charState = CharState.Custom;
    KickStarter.player.GetAnimator().Play("BusterShocked_R");
    

    Is there a clean solution for this? I only need custom animations in rare exceptions so it would be good if I don't have to change everything.

  • What is the Player's state at the time? Are they moving?

    Try calling their Halt function to stop them moving immediately.

  • Yes that works. Thanks again!

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.