I’m trying to make my spaceship fire only once when the Fire trigger is pulled on a joystick, but GetButtonDown doesn’t seem to work.
function Update () {
// Put this in your update function
if (Input.GetButton("JoyFire")) {
var clone : Rigidbody;
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection (Vector3.forward * speed);
}
}
This is code that works, but rapid fires projectiles… which would be fine for certain weapon types, but I want this particular weapon to only fire once when triggered. If I change Input.GetButton(“JoyFire”) to Input.GetButtonDown(“JoyFire”), nothing happens when the trigger is pulled.
I’m guessing this is a limitation in how joysticks are handled? Anyway, looking for suggestions on this one. Thanks!