I have a firing script, as shown below. How do I add a sound that plays whenever the gun fires? It is a machinegun, so it needs to loop when you hold down the button.
var projectile : Rigidbody;
public var speed = 10;
public var destroyTime = 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, destroyTime);
}}
↧