Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Jump toggle

Discussion in 'Scripting' started by Cactus_on_Fire, Jan 4, 2015.

  1. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Hello.

    How can I make the character jump as soon as it hits the ground if you press and hold the spacebar ? I need it constantly jumping with no wait time when spacebar is being pressed.
     
  2. Crayz

    Crayz

    Joined:
    Mar 17, 2014
    Posts:
    192
    You can use a conditional to check Input.GetKey(KeyCode.Space) and that your character is grounded within Update(), if both are true run your jump method
     
  3. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Oh I just noticed this line, which disables the jump right after the button is pressed :
    if (jumping.enabled && canControl && (Time.time - jumping.lastButtonDownTime < 0.2 )) {

    So I just changed the 0.2 to 100 :)