Detect if a Player is within a Spotlight?

Hi, I’m already an Unreal user, but I’m new to programming and blueprints.
I was wondering if there is any way to detect when the player has entered a spotlight’s outer cone area. In other words, I want to use a spotlight as a trigger.
Can you help me please? I tried so many ways but I’m stuck…
Thanks in advance! :slight_smile:

the spotlight needs to be inside an actor

in the actor add a cone as a component and make it as large as the outer radius of the light.

then set the collision response to overlap pawn and in the event graph check for overlap events.

on beginoverlap = Player is in light.

on overlapend = player is not in light.

also make sure to check Hidden in game option so that the cone is not visible in the game.


Ohh! Thank you very much! I didn’t tought on that solution, it’s pretty effective! And thaks for the screenshots :smiley:
Is there any way to make the cone as large as the spotlight’s outer radius automatically? I mean, that the cone size change when I change the outer cone angle so I don’t have to do it manually everytime. I don’t know how to isolate the Spotlight’s outer cone radius.
Thanks again!

You can use a construction script to scale the cone appropriately when the actor starts up.

Interesting. I have never done it that way.

Thank you very much @jwatte I don’t really know how to use the Construction Script but I will digg into it, let’s see If I manage to do it!

@StephanieHarmon did you do something like that before? All the methods to archive it are valid, so it will be great if you want to share it.
I know there’s a way to do it via Line Traces ad comparing the angle of the spotlight and the angle of the spotlight-player angle, but I don’t know how to build the blueprint

I’m on the phone and don’t have the link currently but someone on YouTube gave a way a free project with line traces.

That said, it’s about all the lights (or the ones you apply the blueprint to) and it’s used to check how visible the player is and by what color lights, calculating the falloff and tracing to different parts of the body, so probably a bit advanced for what you want.

Plus it was for an older version of ue4 and when I tried it on 4.25 it had issues with the traces never deleting themselves and slowing it down to a crawl as you moved around.

If you find it, it’s really good to go through and see how it’s done but it’s not ready to be used in a game. For your question, I’d suggest doing what @bumbumgoesnuts suggested. The packaged project I mentioned is intended for stealth sims a lot more so than simple stealth mechanics. Think Thief vs AC about the complexity it offers.