- Home /
Problem with continuous animation on instanced object
Hello! I'm having a problem with the animations of the helicopters of my game. The helicopters are all instancies of a prefab. They have two animations: one for the take off, and one for the rotation of the rotors. The take-off animation must play once, while the rotors animation must play continuously. As you can see in this video, the problem is that the first instanciated helicopter plays both the animations once, so the rotors stop after the first rotation. https://www.youtube.com/watch?v=9xhGrdTw6aw
Here is the code that I use: For the creation of each helicopter:
var newUnit : GameObject = Instantiate(units[unit_type], cell.transform.position, Quaternion.Euler(new_unit_rotation));
for the animations:
var scene_heli = GameObject.FindGameObjectsWithTag("heli"); //creates array with helis for(heli in scene_heli){ //for each heli in scene, set the loop type and play animation heli.animation.GetClip("rotazione_rotori").wrapMode = WrapMode.Loop;
heli.animation.Blend("rotazione_rotori");
heli.animation.GetClip("decollo").wrapMode = WrapMode.Once;
heli.animation.Blend("decollo");
}
The very strange thing is that all other helicopeters work fine, while the first never works. Can someone give me a solution? Is mine the correct way to start those animations?
Thanks!
Please refrain from bumping your question unless it's at least more than a month old. There are unanswered questions from 09 still here so just get in line and be patient :)
Your answer
Follow this Question
Related Questions
Rotate to a set degree then reverse and repeat 1 Answer
Camera shake loop in main menu? 1 Answer
My animation only plays on loop 1 Answer
Animation stoping!! 1 Answer
Zooming animation doesn't work 1 Answer