The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

New to Photon. How can I make sure the players spawn in the right place?

GarrysToenail
2022-01-30 16:22:07

Just picked up Photon today and am looking at spawning my players. There's a spawn for the first player and the second player but I don't know how I can make sure Player 1 spawns at the first spawn and Player 2 spawns at the second.

I saw this code by BlackThornProd which would theoretically work fine because you don't need to check if a spawn is taken. But in my case I probably do and if I try to check that via a script it'll probably be false on the client for the second Player and true on the client for the first Player

Comments

Klover
2022-02-09 11:59:17

public List playerList; //When a player is Instantiated in the scene add them to this list.

foreach(GameObject otherPlayer in playerList)

{

if(transform.position == otherPlayer.transform.position) //If your position is equal to another player's position just send yourself to another spot but to be honest this probably won't happen because Random.Range is typically so vast that it never happens.

{

}

}

Back to top