Quantcast
Channel: Recent Discussions — Photon Engine
Viewing all articles
Browse latest Browse all 15755

Spawn players in unique places Please helpppp

$
0
0
Ok i give up...thats why im posting this. I just cant figure out why my variables arent updating.

Currently this is how i am spawning the player:

spawnPoints = GameObject.FindGameObjectsWithTag("pSpawnP");
bool spawned = false;
while(!spawned){
int randS = Random.Range(0, spawnPoints.Length);
if(spawnPoints[randS].transform.childCount == 0){
GameObject insPlr = PhotonNetwork.Instantiate(playerPrefabE[selectedModel].name, spawnPoints[randS].transform.position, spawnPoints[randS].transform.rotation, 0);
insPlr.transform.SetParent(spawnPoints[randS].transform);
spawned = true;
}else{
spawned = false;
}
}

In my scene i have spawn points with photon views. When i spawn my player i check if a spawn point has a child and if it doesnt i spawn it and set that spawn point as the parent to my player. However when other players join they cant see that i am a child of the spawn point. The spawn point isnt synchronizing its children.

I also tried making a script for the spawn points and setting a bool to false. When i spawn the player i check if its false and then spawn the player and set it to true. I set this variable using a PUNRPC call, but when other players join the game they cant see the updated variable. I tried using an int and setting it to 0 when not occupied and 1 when occupied but when players enter they cant see it update. I also tried putting the variable in PhotonOnserializeView and i tried different observe options and still when players enter the match they cant see the updated variable, just the default.

Am i missing something? How do i sync a variable for players that havent joined the match yet, or how can i sync a spawnpoint and the child object to new players entering the match.

thank you,
chris


Viewing all articles
Browse latest Browse all 15755

Trending Articles