Ok, so I created a new project to test this. Put two players side by side with text above their heads with their current health. If the player presses enter, their health goes down by 1. Horrible game, good test.
Using RepNotify… it all worked perfectly.
So I deleted everything I had in my current project and re-made it from scratch. It seems I fixed one problem, though I’m not certain where. Another still persists.
At the moment, each players’ “health” value is updating properly. The HUD, however, is not. When one player’s health changes, both player’s HUD’s are updated to show the health of the last person to get hurt. At this point, it’s come down to my lack of experience with HUD’s. When you assign a HUD to a game mode, I just assumed each player had their own version of the HUD and variables used there were player specific, just like with the character. However, it seems I am wrong. So when I tell the HUD to display the health of the damaged player, it does… for everyone.
Is there a way to instance the HUD so that each player has their own? I thought it was linked to the PlayerController for which each player should have their own, but I must be confused.
Edit: I found a way around it, but I don’t like it.
What I was doing: In the On Rep Health function, I was getting the Player Controller from Player Index 0 (I though each client always referenced them self as “0”), getting the HUD, casting it to my custom HUD, and calling the custom function “Update Health” which just passes in the new health value, then the HUD displays it. This is how I would prefer to do it.
What I changed it to: “Health” is now “Replicated”, not “Rep Notify”. When the HUD runs, it gets the Owning Player Controller, then the Controlled Pawn, casts it to my character, and calls a custom “Get Health” function which gives it the current health value and it displays. This works, but I don’t like that I need to call this function for every time it redraws the HUD rather than only when a HUD element changes.