On joining room create new actor with specific a role
I'm creating a game with players and one observer who can join a room. I have these 2 flows:
ClientA => create a room [A] => create actorA (player) => create new model = 3D character
ClientB => join room [A] => create actorB (observer) => setCustomProperty('observer', true) => create new model = camera
The problem I'm facing is when ClientB is joining the room [A], clientA has onActorJoin triggered immediately but the custom property 'observer' is false and then it starts to create a new model as a 3D character and I don't want to create a character, as this actor is an observer which should be a camera only for ClientB.
- What would be the best approach for this use case?
- How to sync all clients to tell them the new actor who joined is an observer? Or is it possible to avoid to dispatch the event onActorJoin through all the connected clients in the room and keep it happening only for the local client?
- The other idea I have is not ideal, but I could define a rule for exemple if 2 players are already part of the room, the 3rd one is by default an observer. But I wish I could do something a bit more flexible.
Thank you for your help.