Allowing only one jump?

I am attempting to allow an animation to only jump once each time the “Jump” button is pressed and also stop the animation from staying at the top of the “Jump” animation if the the button is held.

using UnityEngine;
using System.Collections;

public class BasicCharacterControl : MonoBehaviour 
{
	public Animator animator;
	
	public float rotSpeed = 90f;
	public bool canJump = true;
	public float j;

	void Start () 
	{
		animator = GetComponent<Animator>();
	}

	void Update () 
	{


	}

	void FixedUpdate()
	{

		float h = Input.GetAxis ("Horizontal");
		float v = Input.GetAxis ("Vertical");
		j = Input.GetAxis ("Jump");

		animator.SetFloat ("V Input", v);
		animator.SetFloat ("Turning", h);
		transform.Rotate(new Vector3(0, h * Time.deltaTime * rotSpeed, 0));

		StartCoroutine (ProcessJump ());
	}

	IEnumerator ProcessJump()
	{

This is where the Jump starts

if (j == 1 && canJump == true)
    		{
    			animator.SetBool ("Jump", true);

This is what should stop the jump and not allow it to start again until you let go of the “Jump” button

yield return new WaitForSeconds(1);
    			animator.SetBool ("jump", false);
    			canJump = false;
    			print (canJump);
    	
    		}
    		else if (j == 0)
    		{
    			yield return new WaitForSeconds(1);
    			canJump = true;
    		}
    	}
    }

I first attempted to do this without the WaitForSeconds and ran into a similar issue. After reading it seemed this would be a great way to do this. It seems I am still missing a concept here.

If I understand you correctly, simply trigger your jumping code when the button is pressed down and not held. Kinda like Input.GetButtonDown, but you need to write your own version since Axis don’t have that. See this answer for example.

Figured it out. A syntax error was stopping stopping the code from moving forward.

IEnumerator ProcessJump()
{
if (j == 1 && canJump == true) { animator.SetBool (“Jump”, true);

yield return new WaitForSeconds(1);
“jump” should be “Jump”

 animator.SetBool ("jump", false); 
    canJump = false;
     
    }
    else if (j == 0)
    {
    yield return new WaitForSeconds(1);
    canJump = true;
    }
    }
    }

Thank you for the help