- Home /
Photon - Distinguishing player types for spawns
I'm creating a small demo that works over network using Photon. There are two types of "player" that can join, presenters and viewers. Depending on what option you choose in the menu when you join you will have the correct prefab spawn; presenters have been tagged with "presenter" and like wise as appropriate for viewer.
Viewers spawn in anywhere and are invisible so this isn't an issue. Presenters have finite slots and cannot move so must not occupy the same space.
The issue I'm having is this... When I join a room I try and count the objects before (or even after instantiating) it hasn't loaded in other players for me to count so I always get back false information. I've searched around the Photon docs and can't find a lead to solve this.
void OnJoinedRoom(){
// Count how many presenters are in the scene.
presenters = GameObject.FindGameObjectsWithTag("Presenter");
// Spawn an instance of avatar.
spawnedAvatar = PhotonNetwork.Instantiate(Avatar.transform.name, Vector3.zero, Quaternion.identity, 0);
// Set spawn based on count.
avatarSpawnPoint = avatarSpawnPoints[presenters.Length - 1];
// Initialise Position based on spawn point.
spawnedAvatar.transform.position = avatarSpawnPoint.transform.position ;
spawnedAvatar.transform.rotation = avatarSpawnPoint.transform.rotation ;
}
I've even tried moving the spawn point placement to the avatars awake function but that doesn't make a difference. Any ideas?
Your answer
Follow this Question
Related Questions
Help with Photon Network Functions C# 2 Answers
Handle device offline status 0 Answers
Photon handling spawn object with master client 1 Answer
Photon Instantiate once at startup? 0 Answers
RPC and inheritance 1 Answer