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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How Do I Make An Object Jump

Discussion in 'Scripting' started by Gottling, Jan 21, 2016.

  1. Gottling

    Gottling

    Joined:
    Jan 1, 2016
    Posts:
    6
    I Have Made A Script So My Cube Can Move Around But I Can't Figure Out How To Jump,
    Someone Help!!
     
  2. martinmr

    martinmr

    Joined:
    Mar 25, 2015
    Posts:
    325
  3. Gottling

    Gottling

    Joined:
    Jan 1, 2016
    Posts:
    6
    oh thanx
     
  4. blutackboy

    blutackboy

    Joined:
    Nov 19, 2014
    Posts:
    4
    In case you still need help or anyone that comes across this in the future (c#):

    // rename jumpscript to your script name
    public class jumpscript : MonoBehaviour {

    public float moveSpeed;

    void Update () {
    // make sure "Up" button is space or what ever button you want in the input manager
    if (Input.GetButton("Up")) {
    transform.Translate (Vector3.up * moveSpeed * Time.deltaTime);
    }
    }
     
    MarianaPH likes this.
  5. martinmr

    martinmr

    Joined:
    Mar 25, 2015
    Posts:
    325
    i would use this code @blutackboy fpr climbing a ladder, as this is a constant up movement and not a jump behaviour :)
     
    blutackboy and LeftyRighty like this.
  6. blutackboy

    blutackboy

    Joined:
    Nov 19, 2014
    Posts:
    4
    Ah I see, glad you found a use for it!