So far, I’ve been able to move a ball on a 3-dimensional plane using the arrow keys. But I’m not sure how I should make the ball jump. This is the code I have added to the ball to make it move on the plane:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
public float speed;
private Rigidbody rb;
void Start ()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3 (moveHorizontal,0.0f,moveVertical );
rb.AddForce(movement * speed);
}
}
I want to know what I must add to this code in order to make the ball jump.