- Home /
Won't loop animation (solved!)
I want these animations to loop on button press. They are set to loop on the model, and even in the Animation component every animation wrap mode is set to loop. But these will only make them play the first frame and then return to idle. Here's my code:
function Update (){
if(Input.GetKeyUp("n")){
animation.Play("sit");
//sit using N
}
if(Input.GetKeyDown("m")){
animation.Play("stand_001");
//stand using M
}
if(Input.GetKeyDown("v")){
animation.Play("sleeps");
// sleep on V
}
}
If I try
if(Input.GetKeyDown("b")){
animation("sit").wrapMode = WrapMode.Loop
animation.Play("sit")
it brings up and error saying
Assets/AnimalIdles.js(6,3): BCE0077: It is not possible to invoke an expression of type 'UnityEngine.Animation'.
I'm at a loss
Answer by kidne · Dec 02, 2014 at 05:50 AM
I solved it!! It turns out, Third Person Controller disables the animations. So using a bool, I was able to disable the Third Person Controller component every time an animation plays.
Answer by suribe · Jun 19, 2014 at 02:26 PM
Try something like this:
if(Input.GetKeyDown("b")) {
var clip = animation.GetClip("sit");
clip.wrapMode = WrapMode.Loop;
animation.Play("sit");
}
Nope it didn't work. Same thing, it just plays one frame and goes back to being idle.
Your answer
Follow this Question
Related Questions
Could some wise person please help with this animation problem 1 Answer
how to stop animation loop? 1 Answer
Unity Animation - Loop around a closed loop trajectory 1 Answer
Animation loop stop? 1 Answer
Camera shake loop in main menu? 1 Answer