- Home /
Not playing entire animation when it is called.
Ok, be patient with me, I'm new at this :)
I'm making my first person character crouch when the "c" button is pressed. I want to be able to press the button and the crouch animation be played and then the character comes back up to a standing position. The problem is, when I hit the C button, I get the first 3 frames of the animation, but nothing else! Yes, my animation wrap mode is set to "Once".
 function Update(){    
         // If you press Crouch
     if(Input.GetButtonDown("Crouch"))
     {
         Crouch();
     }
 }
 
 function Crouch()
 {
     arms.animation.CrossFade("MCArm_crouchAll", .1);
 }
also, in this script, I have all the Character Movement scripting. I don't know if this is how you're supposed to do it, but it is how I did it, but I made it so that whenever a key is not being pressed, the idle animation is played: function Update () {
     //If no key presses
     if(!Input.anyKey)
     {
         arms.animation.CrossFade("MCArm_idle", 0.2);
     }
 
     // If you are hitting "Forward"
     if(Input.GetAxis("Vertical") > 0)
     {
         transform.Translate(0, 0, walkForwardSpeed*Time.deltaTime);
         arms.animation["MCArm_walk"].speed = walkForwardAnimationSpeed;
         arms.animation.CrossFade("MCArm_walk", .5);
     }
        //(ETC like this)
I don't know if that is part of the problem or not, but I don't think it is....
How do your other animations work? Are they having any problems? I know when I last imported models in fbx format that ALL the animations where botched. Also, try setting the crouch animation to loop, that might work.
Thanks for the tip, but I fixed it. It was doing this cause I had another animation playing when no keys were pressed.
Answer by CG-DJ · Apr 16, 2013 at 01:20 AM
HA!!! Fixed it!
So anyone who has this problem, this is what I did to fix it. It may be a special case for me because of the way I did my idle animation, but I needed to put my [play idle animation] line inside of a if(!arms.animations.IsPlaying) statement. Thus, if there are no other animations playing, then I will be idle.
     //If no key presses
     if(!Input.anyKey || action == false)
     {
         if(!arms.animation.IsPlaying)
         {
             arms.animation.CrossFade("MCArm_idle", 0.2);
         }
     }
Oh my god thanks so much xD, had the same problem where the idle animation was playing...
Your answer
 
 
             Follow this Question
Related Questions
Animation keeps looping even on WrapMode.Once; 1 Answer
Unity Animation just play once 1 Answer
Play animation with key once 1 Answer
Preventing all animations from playing? 0 Answers
Cannot get sprint animation to play when crouch works fine? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                