Reputation: 95
I'm developing multiplayer cards game in Unity and using in my scene I have a table object with 5 chairs objects for 5 players, and 1 camera.
Is it possible using PUN to spawn all players so that they can see the view from a single camera but sit in different chairs?
For example, I have scene like on photo.
If I'm first or second or fourth player who connected in room, I'm spawned on chair 1 and seeing another 4 players on chairs 2,3,4,5.
If another player's first or second or fourth players who connected in room, They must spawned on chair 1 and seeing me and 3 another players on chairs 2,3,4,5.
Upvotes: 0
Views: 830
Reputation: 1812
Thank you for choosing Photon!
Yes, this is possible in Photon Unity Networking. While I think it's not something related directly to Photon.
I think you can do this in, at least, two different ways:
1- Attach a disabled camera to each player prefab. When a player prefab is instantiated: check if it's local/mine. If it's the case, disable the main camera and enable the camera on the local player prefab just instantiated. the camera should point according to the GameObject's position/rotation.
2- When a player prefab is instantiated: check if it's local/mine. If it's the case, move the main camera to the view according to the position/rotation of the local player prefab just instantiated.
Of course, the spawn positions are known on all clients probably at compile time. And mapping a position to the player is done by position index and actor number.
Upvotes: 0