Hey guys,
I am having problem in building a clone for Space Invaders 1978. My game has 11 columns with 5 rows of aliens. The column has a script that checks for the 1st alien in the row and allows it to fire. The problem is that each column is behaving synchronously with other column scripts Example: if column1 fires a bullet, Column2-11 can’t fire until Column1’s bullet is finished, I want a asynchronous behave such that no columns are dependent on one another.
The ColumnScript is as:
`
public float min = 0;
public float max = 10;
void Start () {
float rand = Random.Range (min, max);
Invoke ("SelectForFire", rand);
}
void SelectForFire () {
if (transform.childCount > 0) {
transform.GetChild (0).gameObject.GetComponent<EnemyScript> ().Invoke ("Fire", 0f);
float rand = Random.Range (min, max/2);
Invoke ("Start", rand);
}
}
`
and the EnemyScript as:
`
public Rigidbody2D bullet;
void Fire () {
float x = transform.position.x;
float y = transform.position.y - 0.4f;
Instantiate (bullet, new Vector2 (x, y), Quaternion.identity);
}
`
How can I fix this?