- Home /
Moving Player only during part of an animation
I have a looping animation that is 45 frames long (1.5 seconds), when it plays I want to translate a game object a set distance over time, but it should be moving only during frames 15-45 (so 1 second). So .5 seconds into the animation at frame 15 i want the object to move a set distance over 1 second. I will use vector3.lerp() for the movement:
transform.position = Vector3.Lerp(startPosition, endPosition, speed * Time.deltaTime);
But how can I get this command to execute at frame 15 of the animation?
Thanks!
Answer by UsmanAbbasi · Jun 12, 2016 at 10:00 AM
You can use animation events to achieve this functionality. This will show you how you to use events: https://www.youtube.com/watch?v=8VG2aK2AGSk
Events tutorial starts at time "2:40" in this video.
Your answer
Follow this Question
Related Questions
Make Animation Loop X Times C# 2 Answers
How to add a fixedUpdate() in the animationwiew using an animation in wrapmode.ClampForever?? 0 Answers
How to call a fixedUpdate() in a clampforever animation?? 0 Answers
How to add a fixedUpdate() in a clampforever animation?? 1 Answer
Trying to manage an Animation. AnimationState.time doesn't adjust the animation 1 Answer