Keep light Intensity value after key event

Hi there!

I have set a spotlight in my blueprint that and trying to turn up the intensity when i hold a key. The thing is that it keeps the light on as long as the key is pressed, but when i release it, it goes back to 0. Anyway to keep the last intensity value when i release the key?

Thanks in advance!

Hey! Thanks for your answer! I’m sorry, but i’m quite new to unreal and trying to learn… How do i set up a check for those values?

Hey DANISINMAS,

there is a blog post from epic that discribes your problem ( Input Action And Axis Mappings In UE4 - Unreal Engine ):

“In both C++ and Blueprints, Axis
events will fire every frame passing
the current value of the Axis while
Action events will have the Pressed
and Released outputs fire as the
key(s) are pressed.”

If you release the input axis, it will have the input 0 and sets the intensity to 0.
If you want to keep the intensity, you could include a check against 0 for the input value or a check for new intensity to be greater then your old intensity.

No problem at all.

If you want to check the axis value against 0, you can use the is greater (>) node
Connect the axis value with A and leave in B the 0.0

If you want to check the new value to be greater then the previous value, create a float variable e.g. called “PreviousAxisValue” and use the “Compare Float” node to check if your current value is greater, equal or smaller then your previous. After that you can execute “Set Intensity” when your current value is greater. After that, store your axis value in the variable “PreviousAxisValue”.

I didn’t tried out the solutions, but they should work. If there is a problem with them or you have any other question, just let me know.

Cheers

Works like a charm! For my case i used the first solution which i think suits better what i need but the second one works too. Thank you so much!