So I am trying to make my character jump with rigidbody.addforce, but it doesn't work. Here is the code(c#):
public class Jump2 : MonoBehaviour {
public CharacterController controller;
public float thrust = 5.0f;
public Rigidbody rb;
// Use this for initialization
void Start () {
controller = GetComponent();
rb = GetComponent();
}
// Update is called once per frame
void Update () {
if(Input.GetButton("Jump") && controller.isGrounded)
{
rb.AddForce(transform.up * thrust, ForceMode.Impulse);
}
}
}
↧