Can someone help me add a break to my verse code loop?

I want to make this verse code loop break when a player enters the mutator zone device and also when the explosive device has exploded. but a can’t figure it out at all.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Characters }
using { /UnrealEngine.com/Temporary/SpatialMath }

A Verse-authored creative device that can be placed in a level

AttachPlayer := class (creative_device):
@editable MutatorZone : mutator_zone_device = mutator_zone_device{}
@editable VFXPowerup : visual_effect_powerup_device = visual_effect_powerup_device{}
@editable ExplosiveDevice : explosive_device = explosive_device{}
@editable WhiteDisk : creative_prop = creative_prop{}
@editable VFXSpawner : vfx_spawner_device = vfx_spawner_device{} # aAdd the radio device
@editable VFXCreator : vfx_creator_device = vfx_creator_device{}

OnBegin<override>()<suspends>:void=
    VFXPowerup.ItemPickedUpEvent.Subscribe(AttachToPlayer)

AttachToPlayer(Agent : agent) : void=
    spawn:
        AttachToPlayerNew(Agent)

AttachToPlayerNew(Agent: agent)<suspends> : void=
    if(FC := Agent.GetFortCharacter[]):
        loop:
            Sleep(0.0)
            PlayerPos := FC.GetTransform().Translation
            PlayerRot := FC.GetTransform().Rotation
            spawn{WhiteDisk.MoveTo(PlayerPos + vector3{Z:= -70.0},PlayerRot, 0.1)}
            spawn{MutatorZone.MoveTo(PlayerPos, PlayerRot, 0.1)}
            spawn{ExplosiveDevice.MoveTo(PlayerPos + vector3{Z:= 120.0}, PlayerRot, 0.1)}
            spawn{VFXSpawner.MoveTo(PlayerPos + vector3{Z:= 70.0},PlayerRot, 0.1)}  # Move the radio device
            spawn{VFXCreator.MoveTo(PlayerPos + vector3{Z:= 120.0}, PlayerRot, 0.1)}

You might want to take a look at race expressions, in your case, a valid template would be :

if(FC := Agent.GetFortCharacter[]):
    race:
        # Exit condition (explosive device)
        ExplosiveDevice.ExplodedEvent.Await()

        # Exit condition (mutator zone)
        loop:
            MutatorEnterer := MutatorZone.AgentEntersEvent.Await()
            if(MutatorEnterer = Agent):
                break # Breaks the inner loop then win the race

        # My tick update loop
        loop:
            Sleep(0.0)
            # Add your MoveTos here

Note that the MoveTo calls won’t be canceled right away when the explosive device or the mutator condition wins the race, since you’re spawning those MoveTo calls

1 Like

tysm bro!

1 Like