Using Line Traces To Make Game Objects Hidden In Game

Hey, I’ve been ripping my hair out over this for a few days, I’ve tried leaving it alone until I could find the right answer, but it’s been eating at me and I figured I’d just ask here.

I’m trying to make it so that when every raycast to a character is blocked, that character becomes hidden in game.

As you can see, the character that’s in the dark is still visible, and that’s exactly what I don’t want. What I do want is that if every raycast is blocked, then the character is set to hidden in game, and if a single raycast is not blocked, the character is not hidden in game. Each ray is set to a skeleton socket, I’m unsure why there are double raycasts, but it shouldn’t be a problem since the doubles are going down on the Z axis. If someone has a fix for that as well, that’d be nice.

Here’s the blueprint:

Also, if someone could point me towards a way to make it so that the hidden characters slowly fade away like in Project Zomboid, that would be awesome.
Thank you for the help!

Make a function like this, if one trace is hit then actor must be shown and you don’t need to continue further. If all traces did not hit then at the end actor should be hidden.

Thank you for the response, but that didn’t work.

Just glancing at your BP, two issues are really standing out to me. The first is that your branch pin has no input, so it will always be true. In fact, Im not sure how the actor is not being hidden, since the branch will always be true. Second, you aren’t checking if one trace hits. You are setting the visibility on every trace, meaning only the last trace will decide whether to hide the actor or not.

That picture was for the post, I’ve tried a ton of different things to get this to work and I just cleaned up the blueprint to get it legible for the post. I’m really asking what needs to go from the hit result to the branch to get this to work because everything I’ve tried hasn’t worked.

Kaidoom’s logic looks like it should work fine to me (with start and end locations set ofc). A good start would probably be to combine that logic with your current bp for the locations, then post an updated BP so we can see what is going on.

image

Edit: Just realized in the picture the set hiddens are switched from what Kaidoom15 showed. I was messing around with his blueprint setup to see if I couldn’t make something else work, but the problem still persists after switching them back, except that both characters are permanently hidden.

Here is a similar approach:
LineOfSight.zip (871.4 KB)

Very interesting! I will absolutely use the fade effect from your project, and I’ll try the Line Of Sight To node to see if it works for my needs. I’ll give you an update to see if it’s what I need.