how can i change the energy parameter of a Light2D node from script ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Goldryn

hi, i am new to godot and i need some help.

the game is a 2d side scroller game.

my character carries a torch the map is dark by a canvas modular node and in the map there is an item that i can pick up when i collide with. i want when this item gets picked up the energy parameter of the light2d on the torch to increase and show more of the map.

thanks in advance for help.

:bust_in_silhouette: Reply From: jgodfrey

Since energy is just a property of a Light2D node, if you have a valid reference to the node you can change it like this:

$Light2D.energy = 2.0 # set the value to twice the default

The above assumes you have a Light2D node called Light2D as a direct child of the node containing the above code. If that doesn’t match your scene setup, you may have to season to taste to get a reference to your node.