I have side scrolling game (almost) and I have a little problem with enemy spawnig. I already have spawn points located on map and whenever my BGLooper collides with spawn point it’s gonna move forward, next to last spawn point. I can’t figure how to spawn 1 of my 8 enemies in each spawnpoint randomly. Any ideas?
using UnityEngine;
using System.Collections;
public class BGLooper : MonoBehaviour {
int numBGPanels = 6;
float minEnemy = 1;
float maxEnemy = 8;
void OnTriggerEnter2D(Collider2D collider) {
Debug.Log ("Triggered: " + collider.name);
float widthOfBGObject = ((BoxCollider2D)collider).size.x;
Vector3 pos = collider.transform.position;
pos.x += widthOfBGObject * numBGPanels;
collider.transform.position = pos;
if (collider.tag == "Enemy") {
}
}
}