# We are defining a script that lives inside a Device. # Think of this as the "brain" of the spawner pad. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main script structure. # It inherits from creative_device, meaning it can interact with devices. spawn_truck_script := class(creative_device): # This is a VARIABLE. # In game terms, this is like the "Team Number" setting on a device. # It changes per instance of this script. # Wire this to a Pickup Truck Spawner device in the UEFN editor. @editable TruckSpawner : pickup_truck_spawner_device = pickup_truck_spawner_device{} # This is a VARIABLE. # Wire this to a Trigger device (e.g. a pressure plate) in the UEFN editor. # The trigger fires AgentEntersEvent when a player steps on it. @editable SpawnTrigger : trigger_device = trigger_device{} # This is the ENTRY POINT. # OnBegin runs automatically when the island starts. # It connects the trigger's built-in Event to our Function. # It says: "When a player steps on SpawnTrigger, run SpawnAndSeatPlayer." OnBegin() : void = SpawnTrigger.TriggeredEvent.Await() SpawnAndSeatPlayer() # This is a FUNCTION. # A Function is a block of code that does work. # When the Event fires, this function runs. SpawnAndSeatPlayer() : void = # 1. SPAWN THE TRUCK # We call SpawnVehicle() on our TruckSpawner variable. # This tells the device to create the vehicle in the world. # SpawnVehicle() is the real API on pickup_truck_spawner_device. TruckSpawner.SpawnVehicle() # 2. OPTIONAL: CLEAN UP # If you want the spawner to only work once, you disable it. # Like turning off a light switch after the bulb burns out. # TruckSpawner.Disable()