Without analyzing or testing this too closely, I think the problem you're having is that the Multiplayer.PeerID expression is supposed to work specifically in certain triggered conditions, like OnPeerConnected. When you use it like that outside the trigger, you won't get the right PeerID.
Thanks oosyrag for your thought, I agree mainly that Multiplayer.PeerId have inconsistent behaviour when used outside the OnPeerConnected trigger. Sadly, it seems that OnPeerMessage does not "attached" the context to the created object - not sure if it can be considered as a bug or it's as designed.
An approach I would try (but have not tested), would be to store the relevant peerIDs of each player in an array upon joining, and use that array to look up and assign/associate peerIDs to objects for each player when you want to create player objects.
I have tried to build a JSON object of players with their aliases/objectUid/peerId. The issue is that the objectUid is the one from the host and unfortunately, game object have different objectUid on peer side which prevent me to associate the peerId to corresponding game object. When a player game object is created, only the X/Y/LAYER data are sync until the object is synchronised with the Associate method and none of this is enough to identify a user, except a dirty workaround based on X/Y coordinate but I am really scared about the side effect and prefer to not go on this way...
Hey eleanorjmorel,
While I totally agree with your message, you may need some context to better understand why I have for instance "connected to the signalling server". It's a "cheap" way to distinguish OFFLINE from ONLINE behavior on my event sheet. I could have used "Is inside a room" but anyway, I don't think the issue is linked to that specific things.
As described in my post, I can't use the "on peer connected" event since the peer is already connected for a while. In many game, you don't directly jump to the game screen, you may stay in a waiting room layout until everybody is ready and then be moved from the room layout to the actual game layout. That's the reason why I have used message to inform peer to load a map, and to inform host that the peer has successfully loaded the map.
I could attached a game sample to illustrate the issue but it require me to clean all my assets before. Moreover, the game sample will still have lot of code and may be complicated to debug without spending (lot of) times... not sure to get lot of answers anyway.