Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Change the direction of bullet fire

$
0
0
hello, i am new in unity and didn't understand when i fire a bullet it always goes in opposite direction to gun var projectile: GameObject; var fireRate: float =0.5; var nextFire: float ; var speed : float =5; function Start () { } function Update () { if(Input.GetButton("Fire1") && Time.time > nextFire) { nextFire=Time.time + fireRate; var clone: GameObject = Instantiate(projectile , transform.position, transform.rotation); clone.rigidbody.velocity=transform.TransformDirection(Vector3(0,0,speed)); //clone.rigidbody.AddForce(transform.forward); clone.rigidbody.AddForce(clone.transform.forward * 1000); } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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