Difference between Actor and User

ThinkTwice
edited January 2020 in Any Topic & Chat
Hello guys,

Can someone explain to me the difference between and userId and an actorId. I was thinking all the time they are the same thing until I just realized they are two different things.

1- What is the difference between userId and an actorId? I couldn't find an explanation on the docs.
2 - Since we differentiate between user and actor, is it possible to have more than one actor?
3 - Am I right to assume that I will only be able to set/change the actor id only while inside of a lobby or room? and that the user id would be always possible to change?

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited January 2020
    Hi @ThinkTwice,

    Thank you for choosing Photon!

    1. UserId is string, ActorId or, proper name, ActorNumber is an integer. UserId is valid for a whole 'session' to Photon Servers, starting from the initial connection to the first Photon Server until disconnected. ActorNumber is valid only inside a room and per room. Inside the room you could identify the user by its actor number or if some conditions are met, you could use the UserId. Outside rooms, a user is identified by its UserId (which is the same for 'FriendId', etc.).
    2. A user becomes an actor when joined to the room. The same user can connect to Photon using multiple clients and same UserId. However, we now, by default, no longer allow two actors with the same UserId in the same room. Besides, rejoining a room is now based on UserId (as opposed to ActorNumber before). The rejoining actor gets to keep its originally claimed actor number.
    3. Once connected you can't change the UserId. The UserId is set in the authentication during the initial connection to the first Photon server. The actor number can never be set or changed by the client, the server sets it.
  • ThinkTwice
    edited January 2020
    Hei @JohnTube

    Thank you for the detailed information. It helped me a lot to understand the logic behind the actor and user workings.