Call Random State

Im Pretty new to Unity and making games and im just wondering a thing. If I want the player to spawn on either PositionX or PositionY, How should I do?

Script:

  • Public Transform Player;
  • Public Transform SpawnPositionX;
  • Public Transform SpawnPositionY;
  • If ( 1 > 0)
  • {
  • Player.Position = SpawnPositionX;
  • Player.Position = SpawnPositionY;
  • //Here I want the player to spawn on one of the positions (Random);
  • }

You would do that by using Random.Range.

Public Transform Player;
Public Transform SpawnPositionX;
Public Transform SpawnPositionY;

If ( 1 > 0)    //what is the purpose of this?
{

int rnd = Random.Range(0,1);
if (rnd==0){
    Player.transform.position = SpawnPositionX;
} else {
    Player.transform.position = SpawnPositionY;
}

}