I am making a very simple game with C# but I am using JavaScript for spawning. They respawn fine but the cloned enemies can’t attack me and I can’t attack them. The scripts I have don’t transfer to the spawned enemies. (The game is based off the BergZerg Arcade one but I got bored after the second vid so I did my own thing)
Here is my script for spawning:
#pragma strict
var SpawnCubie : GameObject;
var SpawnPoint : GameObject;
var SpawnCounter : int = 0;
var SpawnCounterMax : int = 0;
function Update ()
{
this.SpawnCounter++;
if ( this.SpawnCounter >= this.SpawnCounterMax )
{
Instantiate(this.SpawnCubie, this.SpawnPoint.transform.position, this.SpawnPoint.transform.rotation);
this.SpawnCounter = 0;
}
}
You should make a prefab of the object you want to spawn, apply any changes to it and then use Instantiate with that prefab instead of referring to the object with the script on it.
This should work strait away if done correctly, instead of Instantiating a copy of the object holding the script, it will spawn an exact copy of the prefab you have saved.