- Home /
Setting Animator animations time.
Heys Guys,
I'm kinda new to mechanim and I wonder if it is possible to set my current playing animation time between 0 and 1 to use random frames with my Animator. My example is that I have 4 characters that I instantiate and I use 2 layers to animate them. The problem is that they are on idle state and they all breed at the same time so I wonder if there is a way to set the current time of my anim (on both my layers) to a certain value so I could make them breed not at the same time as others. Thanks a lot for your time !
Claude
Answer by Siflou · Dec 11, 2013 at 10:44 AM
Hey guys,
Found the answer ! It might help some one. So the idea is to use this Play method on the animator and you can set the normalized time as last parameter and you can tell which layer to play your animation. Here is an example of what I did. Don't forget with your random to explicitly write 0f and 1f because if you go 0,1, it will always be 0 because it is considered as an int number.
Thanks a lot and have a great day
//Breed at at random pace
float random = Random.Range(0f,1f);
mController.Play("Idle",0,random);
mController.Play("Blend_Idle",1,random);