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

bullet wont move forward

$
0
0
i have this script: var projectile : Rigidbody; var speed = 1; var barrel : Transform; var shots : int = 0 ; var maxShots : int = 1 ; var fwd : Vector3; function Update () { fwd = transform.TransformDirection(Vector3.forward); if ( Input.GetButtonDown ("Fire1") && shots < maxShots){ var bullet1 : Rigidbody; bullet1 = Instantiate(projectile, barrel.position, barrel.rotation) as Rigidbody; bullet1.GetComponent(Rigidbody).useGravity = false; bullet1.GetComponent(Rigidbody).AddForce(fwd * speed, ForceMode.Impulse); shots ++; } else if (shots >= maxShots && Input.GetKeyDown(KeyCode.R)) { Reload(); } } function Reload() { yield WaitForSeconds(0.5); shots = 0; } it' s not 100% mine i used some parts of a tutorial but when i add the force my bullet will just float in the air where it is spawned can someone tell me whats wrong cause i honestly thing it should work but it' s probably something small

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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