Disabling jump for 0.25 sec after you hit the ground after jumping?

It’s a minor thing but I wouldn’t want the character to stand on the spot and jump endlessly, a pause in between the jumps would be nice. I thought I might be able to disable the jump using a coroutine but it doesn’t seem to work. Any more experienced programmer see the obvious problem?

I guess I might also ask why the sound of the character jumping sometimes happens twice. I guess when he is jumping he is touching the ground for more than one frame. Not sure how to solve this, I also find it odd that I can’t multiply rotation by delta time. Are there any obvious solutions to any of these issues? :slight_smile:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Character : MonoBehaviour {

    //•How to multiply rotation by deltaTime?
    //•Why can't I give the jump a float?
    //•The jump sound is played twice?

    Transform playerTransform;
    Rigidbody playerRigidBody;

    public AudioSource Jump;
    public Text Gametimer;

    public float characterFSpeed = 4.5f;
    public float characterBSpeed = 2f;
    public float jumpHeight = 150f;
    public bool touchesGround;
    public bool inTheAir;
    public bool jumpEnabled;

    void Start () {

        playerTransform = GetComponent<Transform>();
        playerRigidBody = GetComponent<Rigidbody>();
        playerRigidBody.freezeRotation = true;
        jumpEnabled = true;
	void Update () {

        Gametimer.text = "Time: " + Time.realtimeSinceStartup.ToString();

        //Player rotation, movement and jump.
        playerTransform.Rotate(0, Input.GetAxis("Horizontal"), 0);

        Vector3 forward = new Vector3(0f, 0.0f, Input.GetAxis("Forward"));
        transform.Translate(forward * characterFSpeed * Time.deltaTime, Space.Self);

        Vector3 backward = new Vector3(0f, 0.0f, Input.GetAxis("BackUp"));
        transform.Translate(backward * characterBSpeed * Time.deltaTime, Space.Self);

        if (Input.GetButton("Jump") && touchesGround && jumpEnabled)
            touchesGround = false;
            inTheAir = true;
            playerRigidBody.AddForce(0f, 150f, 0f);


    IEnumerator co()
        if (inTheAir && touchesGround)
            jumpEnabled = false;
            yield return new WaitForSeconds(5f);
            jumpEnabled = true;
            inTheAir = false;


    void OnCollisionStay()
        touchesGround = true;
        Debug.Log("Touching the ground.");

Add another condition to the if getbuttondown(“jump”) add a condition to check if intheair == false.