Download

Turn the light on only inside?

Hello

I have been using unreal engine in a class i have been taking and am currently working on making a single level for an assignment.
In this level i have attached a spot light to the character but would like the light to only turn on when it goes inside a building and turn off when outside.
Wondering if anyone could explain to me how to accomplish this?

Thank You

Place an actor blueprint with a volume in front of the door/building -> add an overlap event -> cast from the character bp into the actor bp -> activate the bool in the character bp in the actor bp -> use the bool in combination with a branch -> activate the light (probably not the easiest way, but it works) :slight_smile:

Just add a trigger to the door ways, or one trigger to the main building, or a trigger to each building. When the player enters the trigger get player character → cast to myCharacter or whatever your character class is. then can fire function turn light on The function is on the character blueprint and simply accesses the light component and sets the enabled value to on. When the player leaves the trigger volume call function turn light off.

If you want to get a bit more fancy in your trigger blueprint expose a variable “turn light on” in the construction script. That way when you place the volume you can tell it if it should turn it off or on. Then just change up your trigger to call accordingly. So on trigger enter, branch turnLightOn = true then call function TurnLightOn. If false TurnLight off. That way the one trigger can be used all over your level and what or how it does can be changed based on what you set when you place the trigger as there will be a check box for TurnLightOn a check means yes, a blank means no.
Could keep getting more fancy but that will / should solve it for your base needs.