user9540087
user9540087

Reputation:

My script for jumpin once does not jump at all

I'm trying to test out a fish that will jump out of the water. My script seems fine except when I press the key nothing happens. I was following a simple tutorial and it seems to work for everyone. What am I doing wrong and how can I make this more simple for when referencing it in my capture script later without key down. This is because the fish will jump on its own later.

public bool onGround;
private Rigidbody rb;

// Use this for initialization
void Start () 
{
    onGround = true;
    rb = GetComponent<Rigidbody> ();
}

// Update is called once per frame
void update ()
{

    if (onGround) 
    {
        if (Input.GetKeyDown ("a"))
        {
            rb.velocity = new Vector3 (0f, 5f, 0f);
            onGround = false;
        }
    }
}

}

Upvotes: 0

Views: 58

Answers (1)

Daxtron2
Daxtron2

Reputation: 1309

Actually, the more likely thing is that your update function is not correctly setup

Change it to

void Update()

Upvotes: 1

Related Questions