Difference between photonView.viewID and PhotonNetwork.player.ID
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Difference between photonView.viewID and PhotonNetwork.player.ID
SN_007
2017-07-06 07:08:59
I have received the list of players through PhotonPlayer.playerList. Now I need to send the message to the certain player. How I am able to do it? I assumed that it is possible with such method: photonView.Find ( PhotonNetwork.playerList[ index ].ID ).
But then I have read that photonView.viewId doesn't correspond to PhotonNetwork.player.ID.
Explain me, please, purpose of photonView.viewId and PhotonNetwork.player.ID: in what their purposes, and in what a differences?
Whether there is between photonView.viewId and PhotonNetwork.player.ID a strong interrelation?
Best regards!
Comments
Hi @SN_007,
Thank you for choosing Photon!
The PhotonView ID is unique per networked object.
The PhotonView could be attached to an actor networked object or a scene networked object.
The player ID or actor number is unique per actor inside the room.
Thanks! This is good information for me!
@JohnTube
I tried following your link above but getting a "page does not exist" message.
Hi @krx,
Here is the snippet from the last link:
PhotonViews send out a viewID for every network message. This viewID is
an integer, composed of the player ID and the player's view ID.
The maximum size of an int is 2,147,483,647, divided by our
MAX_VIEW_IDS(1000) that allows for over 2 million players, each having
1000 view IDs. As you can see, you can easily increase the player count
by reducing the MAX_VIEW_IDS. The other way around, you can give all
players more VIEW_IDS at the cost of less maximum players.
It is important to note that most games will never need more than a few
view ID's per player (one or two for the character...and that's usually
it). If you need much more then you might be doing something wrong! It
is extremely inefficient to assign a PhotonView and ID for every bullet
that your weapon fires, instead keep track of your fire bullets via the
player or weapon's PhotonView.
There is room for improving your bandwidth performance by reducing the
int to a short( -32,768, 32,768). By setting MAX_VIEW_IDS to 32 you
can then still support 1023 players Search for "//LIMITS
NETWORKVIEWS&PLAYERS" for all occurrences of the int viewID.
Furthermore, currently the API is not using uint/ushort but only the
positive range of the numbers. This is done for simplicity and the usage
of viewIDs is not a crucial performance issue in most situations.