Not playing entire animation when it is called.

Ok, be patient with me, I’m new at this :slight_smile:

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…

Come on guys...I'm really hitting a wall here...

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.

1 Answer

1

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...