Control light intensity with controller?

Hey there I am fairly new to UE4 but having a great time so far! Could someone please lend me your knowledge for a second?

I would like to turn the intensity (brightness) of a light up and down while in-game with my controller. Any buttons will do!

Any help would be great! Cheers!

Cam

You can cast to the light and control pretty much any element. There’s two ways to do it.

Create an object variable in your player BP with the class if your light. So you’d use Point Light or Directional Light or whatever for its type. Select the light in your level and right click in the level BP. Create Reference. On Begin Play in the level BP, cast to your character and use Get Player Pawn for the input. From the cast, drag out and set the light variable in your player BP. For the input on setting that variable, plug in that reference you created for that light. You now have direct access in your player BP over the details of that particular light at any time.

Second method takes place entirely in your player BP. Use Get All Actors of Class and select your light type there. You’ll use Get from that and set the integer value to whatever corresponds with that particular light. If there’s only 1, it’ll be set to 0. You then cast to the light type with that result, drag out the output of the cast, and do Promote to Variable. You now have direct access to that light.

Up to you what you use. It probably just depends on how many lights of the same type are in the level.

Once you have that reference in your player BP, you can use whatever input event you like and use that variable to control elements of it.

I can do pics later if you need them. Lemme know if this is what you were looking for

Hi CamRule,

this is a different way to do it in the level blueprint:

By adding a timeline, you can dim the light from its actual value, wich you need to set as first key and zero, the flipflop switches between the a and b output and tells the timeline to play or reverse. Setintensity finaly sets the actual value until the timeline stops. Let me know if something unclear.
:slight_smile:

hey thanks for the speedy reply! I am new to unreal and this sounds great, but I would probably have trouble building it just from words, could you please give me some pics or maybe even a small project file to work from?

Really appreciate your reply as I am super excited getting this to work!

Hey there, thanks for going out of your way to give me another example!

I understand that I am triggering an animation timeline back and forth here, so the next step is to create the animation of the light getting brighter and to the end of the timeline. How would I go about doing this? Thanks so much for the input and screenshots!

Hi CamRule,

you can add a node by rightclicking into the blueprint,
then search in the contextmenue for “add timeline”,

once its in the blueprint, double click it and add one float track

in the timeline and name it to lightintensity.

Then you can decide the length of the timeline and by shift+leftclick you add a keyframe. Do it at the beginning, set the value to the actual intensity value of the light and adsd another keyframe at the end
, set its value to 0.

Select the keyframes and rightclick to change its interpolation from linear to auto to have a smooth fade.

Get back to the tab of your blueprint, you will see a new connector connect everything like in this picture and it should work.

Hey thank you for the in depth answer! I will be working on this tomorrow, thanks again I look forward to getting this to work on my own project!

Hey there, thank you I got it to work! But! I want to press and hold to change intensity, but when I let go of the button I want the light to stop at the current intensity. Also I would like one button to play it forward, and one button to play it backwards, both being able to stop when I let go of the button. Can you help me please?

I got it to work by removing the flip flop and just connecting one button to play and the other to rewind, both also to stop when release so they do not continue after releasing a button

Good job :slight_smile: your world of developing mechanics in BPs just opened up quite a bit

I have one Button on Widget , when i taget on Button , I want play time line in Actor ??? , Help me

I have one Button on Widget , when i taget on Button , I want play time line in Actor ??? , Help me