using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } using { /Verse.org/Colors } # This is our main device. It controls the door. # It watches a trigger_device and changes a # customizable_light_device to simulate a glowing door. glowing_door_device := class(creative_device): # A reference to the trigger placed in front of the door. # Wire this up in the UEFN editor. @editable EnterTrigger : trigger_device = trigger_device{} # A reference to a customizable light device on the door. # Use a customizable_light_device to fake the glow effect. # note: Verse cannot write directly to mesh materials at runtime; # a customizable_light_device is the closest real API for # changing color on a prop dynamically. @editable DoorLight : customizable_light_device = customizable_light_device{} # OnBegin runs once when the game starts. # We subscribe to the trigger events here. OnBegin() : void = # Subscribe to player-enter and player-leave events # on the trigger device. EnterTrigger.TriggeredEvent.Subscribe(OnPlayerEnter) # This function runs when someone enters the trigger. OnPlayerEnter(Agent : ?agent) : void = # Turn the light bright blue to simulate a glow. DoorLight.TurnOn() # This function runs when someone leaves the trigger. # note: trigger_device only exposes TriggeredEvent (enter). # To handle "leave", add a second trigger_device around the # door exit, wire it to a second glowing_door_device whose # OnPlayerEnter calls TurnOff with the dark values below, # or use a timer_device to reset after a delay. OnPlayerLeave(Agent : ?agent) : void = # Change the light back to simulate no glow. DoorLight.TurnOff()