I currently have an enemy with a script attached to it so it interacts with the player. Today, I also added a simple spawn system to get started with spawning enemies in the scene, but the enemy clones my script spawns do not interact at all like the original enemy object does. How can I make the clones behave the same way as its original object does? The scripts, audio, animation, meshes, etc. all transferred to the clones when they spawn, but the clones just stand idle as if no scripts were added to it. An example being my original enemy object chases my player when it gets close, but the clones don't.
The GameObject is the enemy prefab that I have. The original enemy prefab chases the player with a script I gave it, but its clones don't when they spawn from the script below. public float counter; public GameObject enemy; // Use this for initialization void Start () { StartCoroutine(EnemySpawn()); } IEnumerator EnemySpawn() { enemy = GameObject.FindWithTag("Enemy"); for(counter = 1; counter < 6; counter++) { Instantiate(enemy, transform.position, Quaternion.identity); yield return new WaitForSeconds(1.5f); if(counter >= 6) break; } }
Can you paste the original "chase" script as well? Also, there's no reason to check if counter >= 6 to break the loop if the highest index of the for-loop is 6.
@ FlightCrazed Thanks for the link to that tutorial. Helped a lot more. @ mafiadude1 Thanks for the help as well. I set counter >= 6 to break just to be sure in case it glitches and jumps past 6 for whatever reason, but I'll set it to check at 6 and see what happens.
If you want to make sure it doesn't go past 6 then you should probably put that if block before the instantiate