Verse Library verse

01 Fragment

Loops through players to match each with a starting position and enable linked vehicles or barriers.

verse-library/set-up-the-player/01-fragment.verse

# This is a function. Think of it as a custom command you can give the game.
# It takes one input: Players, which is a list (array) of player objects.
# <suspends> means this code might pause to wait for things to load (like cars spawning).
SetupStartingPositions(Players:[]player)<suspends>:void=
    # 'Index' is the number (0, 1, 2...) and 'Player' is the actual person.
    # We loop through every player in the list.
    for:
        Index -> Player : Players
        # Here, we grab the Starting Position that matches this player's index.
        # If Player is the 1st in line, we get the 1st Starting Position.
        StartingPosition := StartingPositions[Index]
        
        # We grab the specific devices attached to this starting position.
        # These are references to devices you place in the UEFN editor.
        Vehicle := StartingPosition.Car
        Barrier := StartingPosition.Barrier
        
        # The 'do' block runs for every player in the loop.
        do:
            # Enable the vehicle so the player can drive it.
            # This is like flipping a switch to turn on the engine.
            Vehicle.Enable()
            
            # Enable the barrier. 
            # In a race, this might be the gate dropping. In a lobby, 
            # this might be the wall keeping them in the spawn room.
            Barrier.Enable()

Comments

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