# This is the main script for our spawning machine. # It lives on a trigger_device placed on the island. using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /UnrealEngine.com/Temporary/SpatialMath } using { /Verse.org/Simulation } # pop_up_prize_device is the name of our class. # It must match the name of your Verse file exactly. pop_up_prize_device := class(creative_device): # A trigger_device placed in the editor. # When a player walks into it, we get an event. @editable Trigger : trigger_device = trigger_device{} # A prop_spawner_base_device placed in the editor. # Point its "Prop Asset" field at your Gift Box in the Details Panel. # This device handles the actual spawning for us. @editable GiftBoxSpawner : prop_spawner_base_device = prop_spawner_base_device{} # OnBegin runs automatically when the game starts. # We use it to connect our trigger to our function. OnBegin() : void = # Tell the Trigger: whenever a player enters, call OnPlayerEntered. Trigger.TriggeredEvent.Subscribe(OnPlayerEntered) # This function runs when a player touches the trigger. # "Agent" is the person who stepped on the trigger. OnPlayerEntered(Agent : ?agent) : void = if (TheAgent := Agent?): # 1. Try to get the Fortnite character for this agent. # We need the character to read their location. if (Character := TheAgent.GetFortCharacter[]): # 2. Get the location of the player. # Think of this as finding the player's feet. PlayerTransform := Character.GetTransform() PlayerLocation := PlayerTransform.Translation # 3. Move the location forward a little bit. # We don't want the box to appear *inside* the player! # We add 100 units in front of them. SpawnLocation := PlayerLocation + vector3{X:=100.0, Y:=0.0, Z:=0.0} # 4. Teleport the prop_spawner_base_device to the new location, # then fire it so a fresh copy of the prop appears there. # prop_spawner_base_device manages its own prop asset — set that # asset in the Details Panel under "Prop Asset". GiftBoxSpawner.TeleportTo[SpawnLocation, IdentityRotation()] GiftBoxSpawner.SpawnObject()