0
\$\begingroup\$
  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?

\$\endgroup\$
2
  • 2
    \$\begingroup\$ 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? \$\endgroup\$
    – Zibelas
    Jun 17 at 18:09
  • \$\begingroup\$ 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? \$\endgroup\$
    – Kevin
    Jun 18 at 3:48

0

You must log in to answer this question.

Browse other questions tagged .