Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Spawning random enemies in spawn points

$
0
0
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") { } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>