Get player from server function

I’m not sure what do you mean by getting the exact player? The player who called the function on the server? If so, you don’t have to reference anything. I’ll try to explain this as simple as I can. Let’s say that a client player wants to equip a sword:

  • Client: Hey server, I want to equip this sword in my inventory. (ServerEquipSword)
  • Server: Alright, let me check if you have the sword in your inventory in the first place. (ServerEquipSword_Validate)
  • Server: I see the sword in your inventory, I’m equipping it for you. (ServerEquipSword_Implementation)
  • Server: Hey client, I equipped the sword for you. (ClientSwordEquipped rpc sent)
  • Client: Thanks! (ClientSwordEquipped rpc received)

The transition between client/server is done via RPC calls. I think you are familiar with this already. Here is the important part. You don’t have to reference a player, because the server has a copy of the clients as well. When you call ServerEquipSword() on your player, the server will see that this player (in the server’s view: the player who called the RPC on himself basically) wants to equip a sword. So you literally stay in the same class. You don’t have to access which player equipped the sword, because your own copy equips the sword on the server.

Hopefully this makes sense lol
Also, if you want an actor that everyone can communicate with, check out the GameState class.