New to Photon. How can I make sure the players spawn in the right place?
The whole answer can be found below.
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).
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
public 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.
{
transform.position = new Vector2( Just randomize some coordinates again);
}
}
Back to top