Verse Library verse

02 Fragment

Selects a random active player at match start and stores their agent reference for later gameplay logic.

verse-library/runs-when-the-device-is-started-in-a-running-game/02-fragment.verse

# GetRandomInt(Min, Max) returns a random integer between Min and Max (inclusive).
# AllPlayers.Length gives the total count; subtract 1 for a valid last index.
RandomIndex : int = GetRandomInt(0, AllPlayers.Length - 1)
if (RandomPlayer := AllPlayers[RandomIndex]):
    set KillerAgent = option{RandomPlayer}

Comments

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