Hi, I would like the player to be unable to shoot while the projectile is travelling. I’ve got collisions set up for when the bullet hits something. I know I can do this using booleans, but I’m not entirely sure how.
Gun Script:
using UnityEngine;
using System.Collections;
public class ProjectileCS : MonoBehaviour
{
//public variables
public Rigidbody projectile;
public float speed = 20.0f;
public Rigidbody instantiateProjectile;
// Update is called once per frame
void Update ()
{
//input
if (Input.GetButtonDown ("Fire1"))
{
instantiateProjectile = Instantiate (projectile, transform.position, transform.rotation) as Rigidbody; //Object to clone, the position, the rotation
//Moving projectile
instantiateProjectile.velocity = transform.TransformDirection (new Vector3 (0, 0, speed));
}
}
}
Any help would be great.