Tuesday, 9 February 2016

From uNet to PUN #2

Yesterday I tried setting up player objects via network instantiation. Something, however, didn't feel right. Took me a while to realise that the build was setting up for UNET, not PUN.

Most networking APIs require that we filter input (or adjust prefab config) to avoid every player controlling everybody else's. PUN uses PhotonView.isMine for this. Since I don't know what makes a prefab 'mine' I guess being the client calling Network.Instantiate is what does it.

with tweaks, PhotonTransformView works well. In my case physics are important, my setup:


I set remote prefabs to kinematic otherwise local physics interact (poorly) with remote sync.

Spawn location

For generating spawning positions, I used the player joining order
(calling PhotonNetwork.otherPlayers.Length inside OnJoinedRoom).

Exit a game session

In Photon, Disconnect() appears to correctly exit the 'room' and disconnect the client.

Time spent: ~2-3 hours

No comments:

Post a Comment