Okay so I'm making a 2D video game in the style of Space Invaders, but I'm having an issue where the enemies on the top row shoot those on the lower rows. I honestly don't know how to stop them from shooting. I have considered raycasting, but I haven't used that in a long time, and never on a 2D product. My current script controlling when they shoot looks like this:
#pragma strict
var enemyShot : Transform;
var shotTime = 1000;
var timeToShot = 0;
function Start () {
}
function Update () {
timeToShot ++;
if (timeToShot == shotTime){
Instantiate(enemyShot, transform.position, transform.rotation);
timeToShot = 0;
}
}
↧