How do I stop my animation from looping while I hold down a key?

I need my animation to stop looping while I hold down the Up-Arrow-Key.
There are some other functions behind that needs the condition to be just GetKey, NOT GetKeyDown. I also need the animation.play to be on a boolean condition for some other functions behind.

I also tried setting the WrapMode to just Once.

Oh and the animations are attached on the object’s Animation Component.

Here’s the code:

//I need this to be GetKey, *NOT* GetKeyDown
if (Input.GetKey (KeyCode.UpArrow))
	{
		upBool = true;
	}

//I need the animation.Play to be on bool too, not on the button's if-statement
if (upBool)
	{
		animation.Play ("UpAnim");
	}

//This loops it over and over while I hold down the Up-Arrow-Key but I only want it to play once.
//Once I start holding the Up-Arrow-Key, it will stop looping and just stay on the last frame of the animation.

Thanks :slight_smile: :slight_smile: :slight_smile:

Is animation.Play(“UpAnim”) is in Update?
If so, it’s called on every frame, i guess that’s why it’s looping. Also, make sure you animation is not set to loop in the inspector.