The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

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).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

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

JohnTube
2017-07-06 08:57:34

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.

SN_007
2017-07-10 07:00:52

Thanks! This is good information for me!

krx
2018-07-29 19:14:06

@JohnTube

I tried following your link above but getting a "page does not exist" message.

JohnTube
2018-07-30 10:07:58

Hi @krx,

Here is the snippet from the last link:

For performance reasons, the PhotonNetwork API supports up to 1000 PhotonViews per player and a maximum of 2,147,483 players (note that this is WAY higher than your hardware can support!). You can easily allow for more PhotonViews per player, at the cost of maximum players. This works as follows:

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.

Back to top