- Home /
The question is answered, right answer was accepted
How to do controlled oscillation in animator?
Hello folks! Been trying to find a smooth solution for this but to my surprise I haven't really found anything that covers this quirk.
What I'm trying to achieve is an animation for a character's hand to raise while a button is being pressed, and then lowered when the button is released. I thought I could do this simply by letting the button input control the speed in the animator, but it seems the playback time is sort of unclamped. (so if I raise the hand for three seconds, animator speed at 1. Then release the hand, setting the animator speed at -1, I will have to wait three seconds for the animator playback time to come back within range.
Any ideas for this? So far I haven't found any solutions that account for the animation waiting for player input.
Answer by Bikupan · Aug 29, 2019 at 02:40 AM
As is often the case, naturally I find a solution right after posting the question, as opposed to the 1h of googling prior to the post.
Alright so smoothest way of doing this seems to be duplicating the animation state, reversing the speed on the duplication - then just calling Animator.Play() on each state appropriately. Interestingly, a Play() call with the same animation state will not interrupt itself by default, which was something I was afraid of.
Follow this Question
Related Questions
2D Animation does not start 1 Answer
Damn, HOW CAN I KNOW, IF MY 2d ANIMATION SPRITE IS FINISHED??!! 0 Answers
Animation motion on base layer does not play after additional motion on second layer 0 Answers
Generic Animation Main Rig Doesn't Play Any Animation. 0 Answers
Is it possible to change a skybox material via (Animation)? 0 Answers