Verse Library verse

12 Running A Race While Holding The Objective

Continuously updates indicator positions above a player using concurrent loops and event awaits for state changes.

extracted-snippets/documentation/en-us/uefn/triad-infiltration-8-visualizing-players-holding-objectives-in-verse/12-running-a-race-while-holding-the-objective.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/triad-infiltration-8-visualizing-players-holding-objectives-in-verse
# Local doc:  epic-docs/documentation/en-us/uefn/triad-infiltration-8-visualizing-players-holding-objectives-in-verse.md
# Section:    Running a Race While Holding the Objective
 # Causes the CaptureItemIndicator to continuously follow a player above their head.
 # Races between the update loop for the CaptureItemIndictator, and whether the player
 # captures the item, drops the item, or is eliminated.
 FollowCharacter(FortCharacter:fort_character)<suspends>:void=
     Logger.Print("Spawned FollowCharacter function")
     race:
         loop:
             Transform := FortCharacter.GetTransform()
             spawn{CaptureItemIndicator.MoveTo(Transform.Translation + vector3{Z := VerticalOffset}, Transform.Rotation, UpdateRateSeconds)}
             spawn{MapIndicator.MoveTo(Transform.Translation + vector3{Z := VerticalOffset}, Transform.Rotation, UpdateRateSeconds)}
             # We want to make sure this loop runs only once per simulation update, so we sleep for one game tick.
             Sleep(0.0)
         CaptureItemSpawner.ItemCapturedEvent.Await()
         CaptureItemSpawner.ItemDroppedEvent.Await()
         FortCharacter.EliminatedEvent().Await()
     Logger.Print("Objective dropped or captured")
Copy full snippet

Comments

    Sign in to vote, comment, or suggest an edit. Sign in