- Home /
Shoot only once when clicked
im trying to get a single projectile to be fired every time i click the mouse button. but at the moment i am only getting a continous flow of projectiles. any ideas?
var projectile : Rigidbody; var speed = 1; function Update () { if(Input.GetButton("Fire1")); { clone = Instantiate(projectile, transform.position, transform.rotation); clone.velocity = transform.TransformDirection( Vector3 (0, 0, speed)); Destroy (clone.gameObject, 3); } }
Answer by arenner · Mar 29, 2012 at 07:44 PM
Try using Input.GetMouseButtonDown(0) instead of Input.GetButton("Fire1").
I hope that helps a bit.
Your answer
Follow this Question
Related Questions
Random Gun Jam with Array 1 Answer
Do something only once 1 Answer
Trouble with script to fire a bullet from a handgun 1 Answer
Troubles With A Shoot Script 1 Answer
How to make a gun shoot? 2 Answers