Hi folks,
I’ve a basic cupboard mesh in my scene:
(click the thumbnail to enlarge it)
As you can see, the drawers are modeled separately from the frame. What I would like to do is actually quite simple:
- if the player clicks on them, I want to animate them opening up…
- … and when they are clicked again I want them to close again.
I’ve all the scripting done and everything works smoothly (input, raycasting etc.), except for: the animator part.
The way the animation system in Unity is set up seems to be geared towards situations where:
- there is a looping animation in each state
- transitions from state A to state B transition the animations from animation A to animation B.
In my case, there is no looping going on. I want the open/close animation to play on the state transition.
Can I still use the built-in animator for this? Does it even make sense to use the animator? Or would it be wiser to simply use a Tween library and hard-code this one out?
What I tried is:
- have one 1-frame “animation clip” that shows the drawer in closed position
- have one 1-frame “animation clip” that shows the drawer in opened position
- transition between the states transitions the animation, and thus the position
… but that didn’t really work out. Also, I don’t want the engine to be busy playing animations all the time that effectively do nothing.
