# This is a Verse script. It controls a game device. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /Verse.org/Native } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main device. It is like the brain. # It wires up to a trigger_device and a customizable_light_device # placed on the island in the UEFN editor. ball_sensor_manager := class(creative_device): # Wire this to a Trigger Device in the UEFN editor. # The trigger device watches the area where the ball rolls. @editable BallTrigger : trigger_device = trigger_device{} # Wire this to a Customizable Light Device in the UEFN editor. # This is the light that turns on when the ball arrives. @editable Light : customizable_light_device = customizable_light_device{} # OnBegin runs when the game starts. # Think of it as the "start" button being pressed. OnBegin() : void = # We tell the trigger to listen. # It watches for anything to enter its space, # including physics props rolling into the volume. # note: Verse trigger_device fires TriggeredEvent for # players; for physics prop overlap, enable # "Physics Events Enabled" on the trigger in the editor. BallTrigger.TriggeredEvent.Subscribe(OnBallEntered) # This function runs when the trigger fires. # The agent is the thing that set off the trigger. OnBallEntered(Agent : ?agent) : void = # If the ball enters, turn on the light! # This is like flipping a switch. Light.TurnOn() # Print a message to the log. # This helps us know it worked. Print("The ball hit the sensor!")