# This line imports the core Verse libraries we need. # Think of this as loading the "engine" of the game into our script. using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Fortnite.com/Game } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/SpatialMath } # This is our main script. It attaches to the Vehicle Spawner (Boat) device. # 'vehicle_spawner_boat_device' is the real Verse type for the Boat Spawner placed in your island. # We extend it so we can react to its built-in events. boat_spawner_script := class(creative_device): # VARIABLES: These are containers for data. # We hold a reference to the vehicle_spawner_boat_device placed on the island. # Wire this up in the UEFN details panel by making it @editable. @editable BoatSpawner : vehicle_spawner_boat_device = vehicle_spawner_boat_device{} # We also hold a reference to a trigger_device the player walks into # to request the boat. Wire a Trigger device here in the details panel. # Using a trigger is the standard pattern because vehicle_spawner_boat_device # does not expose a direct player-interact event in the current SDK. @editable InteractTrigger : trigger_device = trigger_device{} # 'BoatAlreadySpawned' tracks whether we have already fired the spawner # so we don't keep spawning new boats. var BoatAlreadySpawned : logic = false # OnBegin runs once when the game session starts. # This is where we subscribe to events — the equivalent of "setting up listeners." OnBegin() : void = # Subscribe to the trigger's TriggeredEvent. # Every time a player walks into the trigger, HandleInteract fires. InteractTrigger.TriggeredEvent.Subscribe(HandleInteract) # HandleInteract is called by the trigger event. # 'AgentOpt' is an optional agent — the player (or NPC) who activated the trigger. HandleInteract(AgentOpt : ?agent) : void = # Check if a boat is already spawned. # If BoatAlreadySpawned is true, we stop here to prevent boat spam. if (BoatAlreadySpawned?): # A boat is already out — do nothing. # (To notify the player, wire a HUD Message device and call its Show() here.) return # Mark the boat as spawned before we fire so re-entrant calls are blocked. set BoatAlreadySpawned = true # Tell the Boat Spawner device to spawn its boat. # RespawnVehicle() is the real API on vehicle_spawner_device. # It activates the device exactly like pressing "Activate" in the editor. BoatSpawner.RespawnVehicle() # Note: the current Verse SDK does not expose a SetDriver() call on # vehicle_spawner_boat_device or a returned boat handle. The standard # workaround is to position the player at the spawn point so they # are standing on/in the boat when it appears, or use a Vehicle Spawner # device with a Player Spawner placed inside it. # If you need to teleport the player to the boat's location, use: if (Agent := AgentOpt?): if (Fort := Agent.GetFortCharacter[]): SpawnTransform := BoatSpawner.GetTransform() if (Fort.TeleportTo[SpawnTransform.Translation, SpawnTransform.Rotation]): return # Reset lets a level designer (or another Verse script) clear the flag # so a fresh boat can be spawned — e.g., after the old one is destroyed. Reset() : void = set BoatAlreadySpawned = false