- Home /
Animator set current animation normalized time.
Hey Guys,
I have asked this question in the past, but I did'nt get any answer. I don't know if it is because it is not possible to do what I want to do but I would really appreciate if some one could help me on that one. The problem is that i have characters that I spawn at the same time and they are beside each other. The all bread at the same time and I wonder if there is some way to tell the animator to set its normalized time to a random value in the current animation (on multiple layer, because their clothing is animated in another layer) so they could breed in an independant way from each other. Does anybody have an idea ?
Thanks for your generous 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);
@Siflou Every time I do an animator.play() it keeps re-entering "OnStateEnter()" Which seems wrong because you are already in that state. Did you find this to? Heres my code: if(stateInfo.normalizedTime >= 0.92f ) animator.Play("STATE", 0, 0.71f); // it calls state enter again.
Your answer
![](https://koobas.hobune.stream/wayback/20220613123914im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Non-existent gameObjects appearing. 2 Answers
Using Ragdoll on character with mecanim animator 2 Answers
What is this "note" in the console? 2 Answers
How to get length of animation in Mecanim? 1 Answer
Macanim Mouse Buttons interaction c# 1 Answer