I have already made a enemy prefab and it’s all goes well.But here comes the question,this enemy has different moving pattern.
may be it will go straightly to me in a line
may be it will make a S curve
may be it will make a U turn…etcetc
I guess there are some smart way’ to solve it rather than to make more and more same prefab with those different script above.
I have tried to declare a array of component variable and want to use GameObject.AddComponent for each instantiated enemy prefab,but it doesn’t work.
so,how can I effectively add different script in a same prefab?
Here is my wrong code
public Component[] enemyMove;
public Component[] enemyShoot;
void Spawn(int waveCount)
{
Instantiate(enemies[waveCount],spawnPositions[waveCount].position,spawnPositions[waveCount].rotation);
enemies[waveCount].AddComponent<**enemyMove[waveCount]**>();
}
which the problem is right here in <>.