(Multiplayer Game) How to make health widget appear above head when other players crosshair is in sight

Hi I tried to attempt doing what the title says but the issue is the health bar appears when other player (server or client) crosshair is in sight of the other player but doesn’t go away when the player looks away. Please Help me been trying for a week and got up to here but now left with 1 issue.

Its the same when the Client looks at the Server or if the Server looks at the Client

Line trace:


Event Graph:

When Server looks at client:

When Server Looks away:

Hey @Harjyot471! Welcome to the forums!

Can you show us where the boolean “Visability” is coming into play? I may be missing something but everything SEEMS fine up til that point. Maybe the bool needs to be followed.

Hi there, thank you for helping me, this means a lot because I am trying to learning UE4 by looking at YT videos and got this far but can’t find the solution to this issue.

I made the Boolean Visibility so when player spawns they can’t see the widget on their head:

This happens here in the event begin play:

Then event tick updates the visibility (on or off) depending on if the players crosshair hits another player and this is where I thought if you grabbed the other players character and then turn on their visibility (on or off) but making sure they can’t see it above there head so I did run on owning client:

Hey! Okay now we’re cooking with gas!

Did you try putting this:
image

In this spot instead?
image
You probably don’t want it running on tick if you can avoid it!
Also you can just use ONE set visibility node with the “Visability” boolean plugged into “New Visibility”! :slight_smile:

Unfortunately it didn’t work but instead got worse Idk if I did it wrong tho. Here is what is happening now:

The health bar above the head is now constantly able to be seen even when both players spawn or look at each other (btw I have no code in the widget) and the health bar doesn’t go away just stays even if other players crosshair detects another player

The code I added from your instructions don’t know if I done it wrong and I removed the branch that would set the visibility maybe that’s why it is showing the health widget above head on spawn

Okay. So here’s what you need to do!

It turns out we were barking up the wrong tree, the problem lays in your line trace, not in your network programming! You’re trying to set visibility to false when there is no stored variable for the previously line-traced player!

So what you need to do is when you hit the other player with the line trace, store them as a variable. Maybe “Last Player Seen”. Then when you go to disable the visibility, you use “Last Player Seen” as your target of Player, grab that health bar widget from them, then set visibility to false :slight_smile:

If that isn’t it or you need more help, please provide code for your line trace so we can straighten that out! :smiley:

I have no clue how to store it in a variable. I am Happy to redo the hole system for this to work.

here is the line trace code:

Please Ignore the other connections going up (Not Connected) that’s because in the meantime I decided to make it show the health widget above head when player is shot and disappear after 1 second.

Try something like this, @Harjyot471 !

To my surprise this worked very well thanks to you but just have 1 issue left if you don’t mind helping

When The Client looks at the Server the heath bar above head is not visible to the Server but the Client can see it just like it should be when aimed at However if the server looks at Client the Client can see there own Health Bar

Server:

Client:

Client To Client:

Event Tick and Custom event (Do Line Trace):

Line Trace: