// This is our "Blueprint" for the game logic.
// It inherits from GameScript, which means it lives in the world and watches everything.
script class CaptureFlagGameScript is GameScript:
#region Variables (The Scoreboards)
// A variable is like a loot box that holds a value.
// We use 'int' (integer) for whole numbers.
// These start at 0.
Blue_Score: int = 0
Red_Score: int = 0
// A constant is a rule that never changes.
// The win condition is always 3 points.
const WIN_SCORE: int = 3
#endregion
#region Events (The Triggers)
// An event is a signal that says "Something happened!"
// This function runs automatically when the game starts.
event OnBegin():
// When the match starts, let's announce it.
Print("Match Started! First to 3 captures wins.")
#endregion
#region Logic (The Brain)
// This is a custom function we will call manually when a capture happens.
// 'team' is a label (like "Blue" or "Red").
function OnFlagCaptured(team: string):
// We use an 'if' statement. It's like a decision tree.
// If the team is Blue, add 1 to Blue's score.
Verse Library
verse
01 Fragment
Implements team scoring and win conditions for a Capture The Flag match using custom game script.
verse-library/build-a-capture-the-flag-in-unreal-editor-for-fortnite/01-fragment.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.