# We need to use the SceneGraph library to talk to the island's objects.
using { /Verse.org/SceneGraph }
# This is our main script class. Think of it as the "Controller" for our island.
SunController := class(VerseActor):
# This function runs when the island starts.
OnBegin<override>()<suspends>: void =
# 1. Find the Directional Light in the Scene Graph.
# We're looking for the object named "DirectionalLight" in the root of our island.
# If you haven't placed one, the editor usually adds a default one.
light_component := GetWorld().GetScene().FindChild<DirectionalLightComponent>("DirectionalLight")
# Safety check: Did we find the light? If not, stop here to avoid errors.
if (light_component == nil):
return
# 2. Define our "Loadouts" (Variables).
# Noon: Bright, white light, sharp shadows.
noon_settings := struct:
Intensity: float = 10.0
LightColor: FColor = FColor::White()
SourceAngle: float = 1.5
# Midnight: Dim, blue-ish light, softer shadows.
midnight_settings := struct:
Intensity: float = 2.0
LightColor: FColor = FColor::Blue()
SourceAngle: float = 0.5
# 3. Create a function to apply settings.
Verse Library
verse
01 Standalone
Finds a directional light in the scene and applies custom intensity, color, and angle settings via a reusable function.
verse-library/directional-lights/01-standalone.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.