Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

How to create smooth jump with rigidbody.addforce?

$
0
0
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); } } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>