Adding jump functionality to basic move script

Hello dear community,

I am new to the unity3d gameEngine and i am trying to learn basic c# scripting.

I got a basic move script and i was wondering how i can add a jump functionality.

This is what i have so far and i am trying to merge the script that i found on the unity scripting reference

public class Player : MonoBehaviour
{
public float movementSpeed = 10;
public float rotationSpeed = 60;

void Update()
{
    float horizontal = Input.GetAxis("Horizontal") * rotationSpeed * Time.deltaTime;
    transform.Rotate(0, horizontal, 0);

    float vertical = Input.GetAxis("Vertical") * movementSpeed * Time.deltaTime;
    transform.Translate(0, 0, vertical);
}

}

Thanks in advance

Have you added a Character Controller to your object?
After you do that, you need to get the component in the update function, and then you can do the movement with the rigidbody’s integrated move command.

In more detail, you can simulate the gravity with a constant movement downwards of the y-axis, and the jump can be simulated with a movement upwards of the y-axis.
Play around with those two values you set until you get a jump that feels right for your game :slight_smile: