RepNotify Confusion - What clients are "notified" using this?

Scenario: Two players with guns. Player1 shoots Player2, both players take 10 damage.

Setup: Player1 presses Left Click, server spawns a projectile.
On overlap, the projectile finds the colliding actor and uses the “Apply Damage” function to damage the player.
The character executes an “On Any Damage Taken” to get the damage and subtract from a “health” variable with RepNotify
The character’s On Rep Health event triggers for both players somehow.

Somehow it seems like when the server updates the Health variable for one player, it notifies both players of this change. Is that how it’s supposed to work? I thought it would only notify the client who owned the actor the script was running on.

Here’s some screenshots of the setup
Bullet’s Event Graph:

Character’s Event Graph:

Character’s “Take Damage” function:

Character’s “On Rep Health” function:

Screenshot in-game:

Edit: Seems like my posts never get answered :-/. Lame.

I have encountered something similar when using the dedicated server option.
It’s pretty weird actually and I can’t explain it myself but even though from the logs you would assume that both clients have the same health after the replication… it’s actually not the case and only the correct character has gotten the replicated health (like it should be).

Try updating a text render component on top of each character every tick with the health number and you will probably see that only one of the character get’s its health reduced.

At least that’s my theory based on what I have encountered before, yours could be a different case!

Actually the reason I noticed this was when my HUD (disabled in the screenshot) was showing both were hurt, so it seems it’s not the same case, unfortunately.

I see… in that case I’m not really sure what could be causing this, the blueprints you showed look pretty normal to me, I did a small test to try and reproduce this problem but it seems it works as it’s supposed to for me.
Is it possible to upload your project? That way I can try and pinpoint where the problem is instead of guessing.

How would I do that without the project being 500+MB?

You could zip the project and then remove the textures folder from the zip (at least in my projects, textures takes most of the space), that should bring the project size down quite a lot.

Ok, tonight I’ll do that. This is really driving me nuts.

For testing, I went into the level blueprint and created a boolean variable with rep-notify set to false, then in the event graph I did “Begin > Set boolean to true”. Then in the On Rep function that got created, I had a simple output of “True”. When I ran it, both clients saw “True”. This makes sense in this context. But I have an older project where I was successfully applying damage to other players using Rep Notify and the setup looks the same as what I have here. Unfortunately it doesn’t run anymore, I broke a macro somehow and now it just complains that it doesn’t exist.

Edit: That other project I was talking about, I had followed this tutorial almost exactly.

So the server initializes “Health” to 100, “Health” is set to “RepNotify”. But in this case, it works. There must be something wrong with my setup… gotta do some intense testing tonight.

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.

I don’t have time to look more into this, but it should be noted that using the Play In Editor feature and Print blueprint node will have all clients print the message, even if you only called Print on one client. As a result, it will look like all clients are getting the same info. This is extremely annoying if you haven’t realized it occurs.

An old post, I know, but I just ran in to this problem working in 4.12. I too am having a hard time understanding why it updates each client. It doesn’t do it if the replicated variables exist on the PlayerController and only if on the player character. For this reason I do most of my replication to the HUD widget from the controller.

Anyway, my quick work-around was this :

this is a repnotify function on my character.

My controller holds the widget, and the controller also has a reference to the controlled pawn. So I just check that the controlled pawn reference matches the Character blueprint the RepNotify is being called on. The hud is now updated on the correct client.

I also had a problem similar to this and realized this is caused by variables that are set on the notify state. You should initialize values every time you run one of their functions otherwise it will access old values that were set before when the function was called on other characters