Hello,
I working on a 2d game where a ship fires a bullet. I would like to only fire 3 bullets but instead is firing 100’s. Im not sure where I went wrong.
here is my script any help would be great
thanks in advance!
kcarriedo
var ufoSpeed : int;
var ufoBullet : Rigidbody;
var ufoBulletSpeed : int;
function Start()
{
transform.position.x = Random.Range( -7,7);
}
function Update () {
amtToMove = ufoSpeed * Time.deltaTime;
transform.Translate(Vector3.up * amtToMove);
if(transform.position.y <= 4.1)
{
ufoSpeed = 0;
FireBullet();
}
}
function FireBullet()
{
var tmp : Rigidbody = Instantiate(ufoBullet,transform.position,transform.rotation);
tmp.velocity = transform.position * ufoBulletSpeed;
}