1
\$\begingroup\$

I have idle & popout animations. Idle- simple scaling up and down 2d object and popout- get the gameobject's position to the right and leave it there. I'm using animator for this purpose. I have a trigger Popout, which when triggered the animator goes from playing the Idle animation to the popout animation. Then another transition from the popout anim back to the idle anim. The problem is that when it gets back to the idle anim, the position gets back to the first one(i.e. as if the popout anim hasn't been played). My goal is, after playing the popout, the gameObject to stay at the last position from the popOut anim and to continue to be scaled up and down(the idle anim). My goal is, the gameObject to keep its last position set from the popout anim(which is to the right of its initial one) and to continue playing the idle anim from there instead of going back to its initial position.

Why does the animator reverses the gameobejct's position to its initial one, after the popout anim has been played?

In this video you can see the problem and what exaclty I'm doing.

\$\endgroup\$
5
  • \$\begingroup\$ What status is apply root motion on the animator? \$\endgroup\$
    – Savlon
    May 22, 2015 at 8:15
  • \$\begingroup\$ Apply root motion is disabled. \$\endgroup\$
    – ZenVentzi
    May 22, 2015 at 8:17
  • \$\begingroup\$ can you post the video onto youtube? I am not going to download your file. \$\endgroup\$
    – Savlon
    May 22, 2015 at 9:38
  • \$\begingroup\$ @Savlon done. The video is now on youtube. \$\endgroup\$
    – ZenVentzi
    May 22, 2015 at 10:16
  • \$\begingroup\$ What is the condition of your pop out state to change to idle? What is the intended action instead of snapping back to idle? \$\endgroup\$
    – Savlon
    May 22, 2015 at 12:25

1 Answer 1

2
\$\begingroup\$

I seen your video and it seems to me that your problem might be in Exit condition of the second animation. You need to have your logic set up like this :

http://gfycat.com/ElasticPastBlackcrappie

In your code you need to set the same toggle state for both your animations. And you need to set the condition for both of them, to work if the toggle is on.

Now after that, you need to realize that, you don't have two states in your animations, you have three.

Idle1 >>> TransitionAnimation1 >>> Idle2

So you will need not just two animation controllers, but three. Once you press toggle, it will run the transition animation, and then after that animation is over, it will switch to the Idle2 state. You won't need any conditions for the transition state, so you will keep everything you have, except you'll add the second state between them.

And I'm not done yet. Your transition state changes between the animations. So you will need another animation controller to go back to the other one. Your controllers should look something like this :

animators

I hope you understand how animations work now. The best extra tip I can give you is to not use animators for basic translations. You see you will need to have 3 extra Animation states now. It's very unefficient. You can just script a boolean that will translate it to Y position when space is pressed, and translate it back to X position when space is pressed again. With only one idle animation that remains the same. Cheers.

\$\endgroup\$

You must log in to answer this question.

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