- Home /
Question by
julianrijken · May 14, 2019 at 06:55 PM ·
animationdoor
How do I reverse a animation mid way?

I have a sliding door with a simple trigger bool
When the opening animation is playing and the bool turns of i want to make the animation play backwards from were it left of, right now it just snaps to the closing animation.
screenshot-68.png
(37.5 kB)
screenshot-69.png
(1.0 kB)
Comment
Answer by julianrijken · May 14, 2019 at 08:32 PM

After some time i found out "Normalized Time" on the state and used it to scroll thru the animation.
This is the code i used.
private void Update()
{
if (colliding && GotItem())
progress += Time.deltaTime * animationSpeed;
else
progress -= Time.deltaTime * animationSpeed;
progress = Mathf.Clamp(progress, 0f, 1f);
animator.SetFloat(parameterName, progress);
}
screenshot-70.png
(2.0 kB)
screenshot-71.png
(15.8 kB)
Your answer
Follow this Question
Related Questions
Can I make animations snap to a frame? 1 Answer
How to open a door with the "E" key 1 Answer
play a door animation with collider 1 Answer
Stop box collider moving with object 1 Answer