c# - Trigger...Spawn...Destroy Unity 3D -


I'm running into a small problem as soon as I hit a trigger, I want an enemy to egg. I just want an enemy on the field. Now when I hit the trigger again, I want an enemy who is on the field so that he can destroy himself, while the next enemy has to underwear. Any ideas about doing this? Do I use a "destroyed" assignment on this? Here I have:

  Public game object enemies; Public float matimer; Zero Start () {Game Object Player = Game Object.Find ("Player"); } Zero span anime () {change the enemy; GameAbuse enemyPointPoint = GameObject.Find ("AnimationPan"); Enemy = Institute (Enemy, Enemyspainpoint Transform. Search, Enemy SpanPo int.transform.rotation) Conversions; } Zero OnTriggerEnter (Collider other) {if (other.gameObject.name == "animatigrar") {mytimer = Random.Range (0,10); Ask ("spawn anime", matimer); Debug. Logs ("spawn normal"); }}}}  

You can store your enemy in a private variable and You can destroy each time before you start a new one in such a way that you have only one of them.

  Private Game Object Enemy = Faucet; Zero Span Anime () {If (Enemy! = Faucet) {Destroy (Enemy); } Game Object enemy spongepoint = GameAbject.Find ("Animospon"); Enemy = Instantiate (enemy, enemypainpoint.transform.search, enemyspainpo int.transform.rotation) as GameObject; }  

Comments