- Home /
Unity Photon:How do i get other player's photonnetwork.player.id when a player collide with other player?
I want to know which player i collided with (other player) on photon multiplayer network.
Answer by aLovedHater · May 23, 2016 at 08:06 PM
As far as i know, photonnetwork.player.id can only return the local player's id. i suggest you give each player their own unique ID when they enter the server to keep track of them individually. If you need this for teams, assign each player a team when they join. This is what i do and it works perfectly :D then if i need to know the individual player on collision i can do something like
public void OnCollisionEnter (Collision collision)
{
playerCollisionObject = collision.gameObject;
Debug.Log(playerCollisionObject.teamID) //teamID is an int //assigned to the player when they join the lobby and their character //spawns that shows what team they're on
Debug.Log(playerCollisionObject.individualID) //teamID is an int //assigned to the player when they join the lobby and their character //spawns that shows what their individualID is.
}
//make sure when you give the player their ID it's throught a PUNRPC so all other clients know each clients ID.. if that makes sense
Your answer
Follow this Question
Related Questions
Android mobile local multiplayer game via Wifi 4 Answers
Photon network won't join random room with a custom property 0 Answers
How do I instantiate multiple game objects using Photon unity network? 0 Answers
How to connect to our own dedicated server using photon networking in unity?(Self-hosted) 0 Answers
unity photon 2 not activate child of specific spawned player 0 Answers