Question by
TheFrostyOnion · May 30, 2016 at 11:47 PM ·
rigidbodycharactercontrolleraddforce
How to create smooth jump with rigidbody.addforce?
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<CharacterController>();
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update () {
if(Input.GetButton("Jump") && controller.isGrounded)
{
rb.AddForce(transform.up * thrust, ForceMode.Impulse);
}
}
}
Comment
Best Answer
Answer by TheFrostyOnion · Jun 04, 2016 at 05:08 AM
I think I have found an answer. It appears that when the object also has a character controller the script doesn't work for some reason.
Answer by starscream97 · Jan 09, 2017 at 04:28 PM
Did you fix it? I'm going through same problem now