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

How to make Roll a Ball Jump? With using UnityEngine.InputSystem; ?

Discussion in 'Scripting' started by DragonNexus3608, Nov 1, 2020.

  1. DragonNexus3608

    DragonNexus3608

    Joined:
    Oct 2, 2020
    Posts:
    1
    Hey everyone! I'm new here. I recently completed the Roll-a-ball tutorial and wanted to improve on it by making the ball jump. Many of the tutorials shown on the internet don't have the using UnityEngine.InputSystem so I'm very lost. What is it that I have to do to make the Roll-a-ball jump? I need it for a assignment.
     
  2. PLSMajesticUnity

    PLSMajesticUnity

    Joined:
    Aug 30, 2020
    Posts:
    10
    well I have been using unity for 2 years now and I don't know how to use the new input system if it should be using the new input system then I am sorry I can't help you but if you could use the old input system then.

    you can add an upward force when pressing a key on the keyboard.
    Code (CSharp):
    1.  
    2. public Rigidbody rb.
    3.  
    4. public float JumpForce;
    5.  
    6. if (Input.GetKey(KeyCode.Space)
    7. {
    8.   rb.AddForce(Vector3.up * JumpForce,ForceMode.Impulse)
    9. }
     
  3. PLSMajesticUnity

    PLSMajesticUnity

    Joined:
    Aug 30, 2020
    Posts:
    10
    you will have to insert the balls Rigidbody from the Editor and the Jump force which will adjust how high the ball will jump when the spacebar is pressed.