How to check if a character is lit by light?

I am attempting to create an AI bot that becomes invisible when in an area with lighting. If there is no light touching the bot I want it to be visible. I cannot seem to find a way to do this though. I’m new to UE4 so maybe this is simple, but I need to find a way because it is the core mechanic of my game. Thanks to anyone who has some advice.

You would probably want to make some collision volumes where your lit areas are, and if they overlap your bots, make them invisible however you want to do that. Light itself is pretty complicated and as far as I know there isn’t a good way to know if something is “lit” because that can mean a lot of things. It depends on what you situation is and how complicated you want your system to be, but rather than using the lighting itself as the way of measuring if something is lit, you should just put collision volumes attached to your lights or in your level where you would reasonably expect someone standing there to be illuminated by your standards.

Try this;

  1. Make Blueprints from those Lights that you want to check if the player is being lit or not by those special ones.

  2. Create Collision Spheres with radius exactly as much as those Lights’ radius.

  3. Create a Bool variable in your character.

  4. In your Light BP, create a begin overlap event by using your Collision Sphere in the event graph.

  5. Drag a wire from “Actor” part of the Begin Overlap and type “Cast to MyCharacter_BP” (The name “MyCharacter_BP” should be what your character’s BP name is. I just gave this one as an example). From the cast, just drag out the new variable you created and set it “True”.

  6. Create an End Overlap by using Collision Sphere again and do the 5. completely same. Only change the last part. Make the boolean “False”.

  7. Summary: Everytime the character gets in the collision, the variable becomes true and whenever he gets out, it becomes false. There you go, now you can check if your character is lit or not. :slight_smile:

PS: I just gave the example as a boolean. You can set the visibility the same way. Alas, Set Visibility Off when overlapping, set it On when it’s not touching.