# How do I instantiate on either side under the same method?

  void TimeToSpawn()
{
float SpawnPosX = -2.77f;
float SpawnPosY = Random.Range(3.86f, 1.75f);
Vector2 SpawnPos = new Vector2(SpawnPosX, SpawnPosY);
if (Time.time > TimeNextSpawn)
{
TimeNextSpawn = Time.time + timeBetweenSpawn;
Instantiate(EnemyOne, SpawnPos, EnemyOne.rotation);
}
}


I only managed to make it instantiate on the "left" side of that box. is there a way to make it instantiate on the right side of that box on this method? or do I have to create another method?

• have you considered adding a parameter to TimeToSpawn if you want to have it to either the left or right? Or do you want to have it randomly to the left or to the right? Jun 17 at 18:09
• On the left side of what box? Your code doesn't reference a box. Which direction are you defining as "left"? Is this the world's -X axis, or relative to the direction a particular object is currently facing? Jun 18 at 3:48