- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
shazi · Jun 10, 2017 at 07:51 AM ·
animationunity 5scripting problemspawn
Issues on spawning the enemy?
Hi geeks, i have an issue on spawning the enemies. When enemies spawn in the game only one plays the animation and functionalities while the others did not play animation and functionalities. When they spawn they are not stable on the terrain and fell down on the terrain. I am attaching the script of spawning enemies, Thanks.
public GameObject ObjectToSpawn;
public int NumberOfEnimies;
private float SpawnRadius=100;
private Vector3 SpawnPosition;
private Vector3 playerposition;
// Use this for initialization
void Start () {
SpawnObject ();
}
// Update is called once per frame
void Update () {
}
void SpawnObject()
{
playerposition= GameObject.FindGameObjectWithTag("Player").transform.position;
for (int i = 0; i < NumberOfEnimies; i++)
{
SpawnPosition = playerposition+ Random.insideUnitSphere * SpawnRadius;
Instantiate (ObjectToSpawn, SpawnPosition, Quaternion.identity);
}
}
Comment