var leftBarrel: GameObject;
var rightBarrel: GameObject;
private var shotIsLeft: boolean;
private var shotIsRight: boolean;
var plasmaShot: AudioClip;
var projectile: Rigidbody;
var projectileSpeed: float = 5;
var fireRate : float = 0.5;
private var nextFire : float = 0.0;
function Start ()
{
shotIsLeft = true;
shotIsRight = false;
}
function Update ()
{
if (Input.GetButton("Fire1") && Time.time > nextFire && shotIsRight == false)
{
nextFire = Time.time + fireRate;
GetComponent.<AudioSource>().PlayOneShot(plasmaShot);
var cloneLeft = Instantiate(projectile, leftBarrel.transform.position, leftBarrel.transform.rotation);
cloneLeft.velocity = transform.TransformDirection(Vector3(0,0,projectileSpeed));
shotIsLeft = false;
shotIsRight = true;
}
if(shotIsLeft != true)
{
nextFire = Time.time + fireRate;
GetComponent.<AudioSource>().PlayOneShot(plasmaShot);
var cloneRight = Instantiate(projectile, rightBarrel.transform.position, rightBarrel.transform.rotation);
cloneRight.velocity = transform.TransformDirection(Vector3(0,0,projectileSpeed));
shotIsLeft = true;
shotIsRight = false;
}
}
that's also didnt helped i know how to handle loops :P but it's don't working, if the loop just runs one time!
– droni