using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } using { /UnrealEngine.com/Temporary/SpatialMath } # This is our main script for the door door_script := class(creative_device): # We wire the trigger_device in the UEFN editor. # Place it around the door so it fires when a player walks close. @editable DoorTrigger : trigger_device = trigger_device{} # We wire the prop_mover_device in the UEFN editor. # It holds the door mesh and handles the sliding movement. # note: Verse has no free-form MoveObject API; prop_mover_device # is the real UEFN device for animating props at runtime. @editable DoorMover : prop_mover_device = prop_mover_device{} # This function runs when the game starts OnBegin() : void = # Subscribe to the trigger so we know when a player is close DoorTrigger.TriggeredEvent.Subscribe(OnDoorTriggered) # This function runs when a player gets close OnDoorTriggered(Agent : ?agent) : void = # Spawn a concurrent task so Sleep does not block other logic spawn{ OpenThenCloseDoor() } # Moves the door open, waits, then moves it back OpenThenCloseDoor() : void = # Make the door move to its Open waypoint (set in the editor) DoorMover.End() # Wait for 5 seconds Sleep(5.0) # Move the door back to its closed position DoorMover.Begin()