I have been struggling to replicate a variable that can differ per player. What I’m trying right now is to:
- Detect server-side when a player collides with a pickup.
- Remove the pickup and increment the player’s pickup count, which is a replicated integer in my custom player state BP
- Draw each player’s number of pickups client-side on his HUD
I’m testing with a dedicated server and two clients. This is my collision event handling:
And HUD drawing:
The problem I’m having is that no matter who triggers the collision event, the pickup count is always increased for Client 1 (event if Client 2 triggered the event). I checked that the event is triggered by the right character: if I destroy the triggering actor, it is the correct one that is destroyed. I also made sure that the player state is replicated, and the variable Num Pickups is as well. Can anyone give me some advice on how to get the variable to replicate to the right client? Am I assuming correctly that server-side each player controller’s player state is only replicated to the corresponding client? Thanks.