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

Can't apply AddForce after Instantiating object

$
0
0
I've been trying out different methods for a shooting script to try and make it as versatile as possible. I've decided on something like this: public GameObject bullet; public float bulletSpeed = 1000f; private Rigidbody bulletRB; void Update () { if (Input.GetMouseButtonDown (0)) { GameObject.Instantiate (bullet, this.transform.position, this.transform.rotation); bulletRB = bullet.GetComponent (); bulletRB.AddForce (this.transform.forward * bulletSpeed); } } But when the object is created it just falls without any force. I know it has something to do with how I'm applying the force, but I can't figure it out. Any help would be awesome!

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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