Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Enemy Shooting delay??

$
0
0
The enemy's cannons' keep shooting repeatedly, I would like for the shooting to be delayed between shots, is there a way to do this? Any help would be appreciated! - Brady Script: #pragma strict var Laser : GameObject; var LeftCannon : GameObject; var RightCannon : GameObject; var range : float = 10f; var myTransform : Transform; var Friendly : Transform; var nextFire : float = 2f; function Start () { } function Update () { var distance = Vector3.Distance(myTransform.position, Friendly.position); if (distance<=range && Time.time > nextFire){ Instantiate(Laser, LeftCannon.transform.position, transform.localRotation); Instantiate(Laser, RightCannon.transform.position, transform.localRotation); audio.Play (); } if(nextFire <= 0){ Instantiate(Laser, LeftCannon.transform.position, transform.localRotation); Instantiate(Laser, RightCannon.transform.position, transform.localRotation); } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles