# LootGoblinScript.verse # This script makes a creative prop teleport when a player enters a trigger. using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /Verse.org/Random } using { /UnrealEngine.com/Temporary/Diagnostics } using { /UnrealEngine.com/Temporary/SpatialMath } # 2. DEFINING THE DEVICE # In UEFN, Verse scripts attached to the level are creative_device subclasses. # We expose the trigger device so it can be wired in the editor Details Panel. loot_goblin_script := class(creative_device): # 3. EDITABLE REFERENCES # Drag your Trigger Device and prop_manipulator_device into these slots # in the UEFN Details Panel. @editable Trigger : trigger_device = trigger_device{} # prop_manipulator_device lets us move a placed creative prop at runtime. # Wire this to a Prop Manipulator device placed on your weapon prop. @editable GoblinProp : prop_manipulator_device = prop_manipulator_device{} # 4. ENTRY POINT # OnBegin runs once when the island starts. We use it to subscribe to events. OnBegin() : void = # Subscribe our handler to the trigger's TriggeredEvent. # Every time a player enters the trigger, OnPlayerEntered is called. Trigger.TriggeredEvent.Subscribe(OnPlayerEntered) # 5. EVENT HANDLER # This function is called automatically each time the trigger fires. # 'Agent' is the player (or NPC) who entered. We cast it to fort_character. OnPlayerEntered(Agent : ?agent) : void = if (ActualAgent := Agent?): # Cast agent to fort_character so we can read their position. if (Character := ActualAgent.GetFortCharacter[]): # 6. CALCULATE NEW POSITION # Get the character's current world transform, then extract translation. CurrentTransform := Character.GetTransform() CurrentLoc := CurrentTransform.Translation # Create a random offset so the weapon jumps near — but not inside — the player. # GetRandomFloat returns a float in [Low, High]. RandomX := GetRandomFloat(-500.0, 500.0) RandomY := GetRandomFloat(-500.0, 500.0) RandomZ := 0.0 # keep the prop on the same horizontal plane NewLocation := vector3: X := CurrentLoc.X + RandomX Y := CurrentLoc.Y + RandomY Z := CurrentLoc.Z + RandomZ # 7. TELEPORT THE PROP # prop_manipulator_device.TeleportTo moves the linked prop instantly. # The second argument is a rotation; we pass the current rotation unchanged. NewTransform := transform: Translation := NewLocation Rotation := CurrentTransform.Rotation Scale := vector3{X:=1.0, Y:=1.0, Z:=1.0} if (GoblinProp.TeleportTo[NewTransform]): # Optional: trigger a visual/audio cue here for player feedback!