Hello everyone,
I’m currently working with a Verse script for a creative device in Fortnite. The goal is to have a prop follow the player who triggers a bomb device. If another player triggers the bomb, the prop should stop following the original player and start following the new player, effectively passing the “hot potato.”
Script:
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
A Verse-authored creative device that can be placed in a level
bomb_logic_new := class(creative_device):
@editable PropFollow : creative_prop = creative_prop{}
@editable BombTrigger : trigger_device = trigger_device{}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
BombTrigger.TriggeredEvent.Subscribe(Triggerit)
Triggerit(InPlayer:?agent):void=
AllPlayers := GetPlayspace().GetPlayers()
if (Player := AllPlayers[0], Agent := agent[Player], Fort := Agent.GetFortCharacter[]):
Fort.SprintedEvent().Subscribe(OnMoved)
spawn:
UpdateCharacter(Fort, vector3{Z:=-90.0, Y:=-0.0})
UpdateCharacter(Player : fort_character, Offset : vector3)<suspends>:void=
loop:
Sleep(0.0)
NewPos := Player.GetTransform().Translation + Offset
if (PropFollow.TeleportTo[NewPos, Player.GetTransform().Rotation]) {}
OnMoved(MoveData : tuple(fort_character, logic)):void=
if (Agent := MoveData(0).GetAgent[]):
if (MoveData(1)?):
else:
What I Need Help With:
- Verifying if my current method for subscribing to player events is correct.
- Best way for unsubscribing from the previous player’s events and subscribing to the new player’s events.
- Any other suggestions
Thank you in advance for your help!