0
\$\begingroup\$

From the unity documentation: https://docs.unity3d.com/Manual/AnimationParameters.html

Trigger parameter: a boolean parameter that is reset by the controller when consumed by a transition (represented by a circle button)

So it should play the animantion once right?

In my current game I already set my animation transition condition to trigger, then in gameObject script I also set the parameter, but it plays more than once.

Here are my animation parameter

Here are my animation parameter

Here are my animation transition condition

enter image description here

And here are my gameObject script to set the parameter

Animator anim;
Start() {
        anim = GetComponent<Animator>();
    }

void shoot() {
        anim.SetTrigger("shoot");
    }

EDIT: this is the transition out of PlayerShoot, returning to PlayerIdle enter image description here

\$\endgroup\$
5
  • \$\begingroup\$ Can you show us your transition back out of PlayerShoot, returning to PlayerIdle? \$\endgroup\$
    – DMGregory
    Aug 17, 2018 at 17:51
  • \$\begingroup\$ @DMGregory ok, I already updated the question, is that what you needed? \$\endgroup\$
    – otong
    Aug 17, 2018 at 17:56
  • \$\begingroup\$ The speed > 0 condition on returning to idle looks a little strange. Was that possibly meant for the transition to the walk state? \$\endgroup\$
    – DMGregory
    Aug 17, 2018 at 17:58
  • \$\begingroup\$ @DMGregory oh yeah, that solved the problem, I forgot to delete the the speed parameter. It used to be integer parameter where I could use isEqual, but then I decided to use float instead. Thank you! \$\endgroup\$
    – otong
    Aug 17, 2018 at 18:03
  • \$\begingroup\$ Feel free to add an answer describing your fix then. :) \$\endgroup\$
    – DMGregory
    Aug 17, 2018 at 18:03

1 Answer 1

1
\$\begingroup\$

Thanks to DMGregory comments that leads to this solution.

Apparently it has to do with the post transition condition. It will play once, but in my case there isn't any valid transition from the playerShoot.

mistakes

As you can see above, I set the speed param to be greater than 0, that leads to invalid transition when the game object is in idle state (speed 0), therefore the animation stays where is at.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .