Animation won't Stop.

When I go to switch a weapon the animation plays but I can’t get it to stop so it can go back to it’s original state.

Here is my script:

var Weapon01 : GameObject;
var Weapon02 : GameObject;

function Update () {

	if(Input.GetKeyDown(KeyCode.Tab)) 
	{
	SwapWeapons();
	}

}

function SwapWeapons() {
	if(Weapon01.active == true)
	{
	Weapon01.SetActiveRecursively(false);
	animation.Play("Sniperswitch");

	Weapon02.SetActiveRecursively(true);
	animation.Stop("Sniperswitch");
	}
	else
	{
	Weapon01.SetActiveRecursively(true);
	Weapon02.SetActiveRecursively(false);
	
	}

}

Any help will be appreciated. Thanks.

1 Answer

1

Taking a guess here, but I’m thinking this probably has nothing to do with the script. (Am a noob myself, so I could be wrong.) Try finding the animation in the project panel, double click on it, and see what kind of wrap mode it has. If it’s on loop, or even default switch it to once and see if that helps. God bless.