Difference between Actor and User
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 Actor and User
ThinkTwice
2020-01-13 18:31:55
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
Hi @ThinkTwice,
Thank you for choosing Photon!
- 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.).
- 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.
- 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
2020-01-15 14:54:14
Hei @JohnTube
Thank you for the detailed information. It helped me a lot to understand the logic behind the actor and user workings.
Back to top