- Home /
Instruct an animation to jump to specific point in timeline
There are plenty of resources out there for using the legacy system, but I want to do this in the new system.
GameManager script needs to instruct another game object / animation (example_1) to jump to a specific point on the timeline based on a variable number [num1]. The old way of doing it uses something like this:
animation["example_1"].time = num1;
How can it be acheived in C# without using the legacy API?
Answer by Baste · Apr 24, 2015 at 03:16 PM
If you need to do this, you can set the animator to be played manually (animator.StartPlayback())
If you do that, the animator doesn't play automatically, but you play it by setting animator.playbackTime. So you'll typically be doing:
void Update() {
myAnimator.playbackTime = myAnimator.playbackTime + Time.deltaTime;
}
A better solution would perhaps be to make a different version of your animation that starts at the point you want to cut to, and have your animator controller transition to that animation with a 0-length transition time. It's not the same as what you'd do with the legacy system, but it's more mechanim-y.
Your answer
Follow this Question
Related Questions
How to create animations that can be edited with scripts in runtime? 1 Answer
Evaluating animation curves in the Timeline 1 Answer
why I have to anim.getComponent in update() function when I had done in Start () function 2 Answers
Why isn't Cinemachine switching between cameras? 0 Answers
First script plays animation but second script stops if from playing said animation 1 Answer