how can I loop my walk animation

I have a animation of 80 frames and when I press the up key it plays the animation but after the 80 frames it goes back to the idle so, if I hold the up key down it plays the 80 frames and while holding the up key it the game switched back to idle until I repress the up key and starts the process again.
I have put the walk animation to loop itself.
my code:if (Input.GetKeyDown ("up")) { anim.Play ("walk"); }
And anim is a reference to the animator component

I hope you can help me out.

If you’re using Animator, on your transitions you could deselect Fixed Duration.

Since from your code, you’re using the legacy style of things, you could do:

if (Input.GetKeyDown("up")) anim.Play("walk");
        if (Input.GetKeyUp("up")) anim.Stop("walk");

Regarding the looping portion of your question, click on the animation itself, and view it in the inspector. You can set the loop style there.

the aim.Stop didn’t work for me so I found what to do

public class PlayerMoving : MonoBehaviour
	void FixedUpdate ()
		float h = Input.GetAxisRaw ("Horizontal");
		float v = Input.GetAxisRaw ("Vertical");

	void Animating (float h, float v)
		if (h != 0f || v != 0f)

and h is the horizontal axis and v is the vertical axis

But thanks for helping cynikal