Penjimon
Penjimon

Reputation: 509

Set mecanim animation playback time/position

I'm trying to set an animator's playback time. (or, start an animation at a specific time) I haven't had success with either approach.

Note: I am setting the Animator (an) in the Start().

Code I've tried:

Public Animator an;

public void SetTime(float time)
{
    an.playbackTime = time;
}

Upvotes: 0

Views: 635

Answers (1)

Penjimon
Penjimon

Reputation: 509

Oops, I guess this one was pretty easy!

I didn't see the constructor options for the Play() method!

The answer:

an.Play("YourAnimation", 0, 0.4f);

However, I am still currious why my original code didn't work. So I figured out how to make an animation play/start at a specific time... Does anyone know how to basically "rewind" an animation to a specific point? (while it's playing)

Upvotes: 0

Related Questions