How to I access the shadows enabled property of directional light through a gd script attached to it?

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

I want let the player use a certain key to turn shadows on and off but do I get access to the shadows?

Also, later I want to implement this feature as a toggle button in a separate settings menu and I am unable to get access to the directional light from the settings menu. How do I do it?

:bust_in_silhouette: Reply From: jgodfrey

You can access the property via the light’s shadow_enabled property. So, this…

$DirectionalLight.shadow_enabled = true # (or false)

To your second question of how to access it from a button in your settings menu… That really depends on how you’ve put your game together, but the most likely answer is via a signal.