Flag System
Flag System
Section titled “Flag System”Capture the Flag Framework
Section titled “Capture the Flag Framework”Flag Actor Implementation
Section titled “Flag Actor Implementation”Create comprehensive flag system for competitive gameplay:
Actor_Flag Components
Section titled “Actor_Flag Components”- Arrow Component: Root for positioning control
- Static Mesh Component: Flag visual representation
- Box Collision: Pickup detection (custom collision, overlap pawn only)
- Team System Integration: Team enumeration for flag ownership
Flag State Management
Section titled “Flag State Management”// Flag State VariablesTeam: E_Team; // Flag ownership (Player/Enemy)Flag_Home: Actor; // Reference to home baseSpawn_Transform: Transform; // Original flag positionAttached_Actor: Character; // Current flag bearer
// Flag Bearer DetectionOnFlagPickup(Character) {if (Character.GetTeam() != Flag_Team) {// Enemy picked up flagAttachFlagToCharacter(Character);DisableFlagCollision();StartDeathCheckTimer();} else {// Ally touched flag - return to base if droppedResetFlagToSpawn();}}
Flag Attachment System
Section titled “Flag Attachment System”Implement flag carrying mechanics:
Character Socket Integration
Section titled “Character Socket Integration”Create flag-carrying socket on character skeleton:
- Socket Name: S_Flag on first spine bone
- Position: X=4, Y=31, Z=-51 (adjust for character model)
- Rotation: X=-13°, Y=80°, Z=90° for natural flag position
- Scale: 0.5 uniform scaling for appropriate size
Flag Attachment Logic
Section titled “Flag Attachment Logic”// Flag Attachment ImplementationAttachFlagToCharacter(Character) {character_mesh = Character.Interface_Get_Mesh();AttachActorToComponent(character_mesh, 'S_Flag', SnapToTarget);Attached_Actor = Character;
// Start monitoring flag bearer healthTimer_Check_For_Dead = CreateTimer(0.25, true);}
Flag Drop and Recovery
Section titled “Flag Drop and Recovery”Handle flag bearer death and flag recovery:
Death Detection
Section titled “Death Detection”// Flag Bearer Death MonitoringCE_Check_For_Dead() {if (Attached_Actor.Interface_Get_Dead_State()) {// Flag bearer died - drop flagDetachFromActor(KeepWorld, KeepWorld, KeepWorld);
// Find ground position for dropped flagLineTraceForObjects(CurrentLocation + 500Z, CurrentLocation - 500Z);SetActorTransform(GroundLocation, SpawnRotation, SpawnScale);
EnableFlagCollision();StopDeathCheckTimer();}}
Flag Home System
Section titled “Flag Home System”Actor_Flag_Home Implementation
Section titled “Actor_Flag_Home Implementation”Create flag capture zones:
Home Base Components
Section titled “Home Base Components”- Arrow Component: Root component
- Box Collision: Large capture zone above base
- Static Mesh: Visual base representation (spawn pad, altar, etc.)
- Team Assignment: Match with corresponding flag team
Capture Detection
Section titled “Capture Detection”// Flag Capture LogicOnHomeCaptureZoneOverlap(OtherActor) {if (OtherActor != Flag && OtherActor.IsA(Actor_Flag)) {captured_flag = Cast(Actor_Flag, OtherActor);
if (captured_flag.Team != Team) {// Enemy flag captured!CaptureFlag(captured_flag);}}}
CaptureFlag(EnemyFlag) {EnemyFlag.DetachFromActor();EnemyFlag.CE_Reset_Transform(); // Return to enemy base
AwardPointToTeam(Team);}
Scoreboard Integration
Section titled “Scoreboard Integration”W_Scoreboard Widget
Section titled “W_Scoreboard Widget”Create simple score tracking interface:
Scoreboard Layout
Section titled “Scoreboard Layout”- Size: 200x50 for compact display
- Team Colors: Red and blue sections (100px each)
- Score Text: Current score display for each team
- Positioning: Top middle of screen, hidden by default
Score Management
Section titled “Score Management”// Score Tracking SystemCE_Score_Red() {Score_Red++;UpdateScoreDisplay();CheckGameEnd();}
CE_Score_Blue() {Score_Blue++;UpdateScoreDisplay();CheckGameEnd();}
CheckGameEnd() {if (Score_Red >= WinningScore || Score_Blue >= WinningScore) {// Game Over - restart levelExecuteConsoleCommand('RestartLevel');}}
Score Integration
Section titled “Score Integration”Connect flag captures to scoreboard:
// Flag Home Score IntegrationOnFlagCaptured(CapturingTeam) {scoreboard = GetWidgetOfClass(W_Scoreboard);
if (CapturingTeam == Player) {scoreboard.CE_Score_Blue();} else {scoreboard.CE_Score_Red();}
// Show scoreboard when point scoredscoreboard.SetVisibility(NotHitTestable_SelfOnly);}
Level Design Integration
Section titled “Level Design Integration”Symmetric Map Design
Section titled “Symmetric Map Design”Create balanced competitive environment:
Base Placement
Section titled “Base Placement”- Two Identical Bases: Ensure perfect symmetry for fair competition
- Flag Rooms: Secure locations for flag placement
- Multiple Routes: Various paths to flag rooms with different difficulty levels
Setup Process
Section titled “Setup Process”- Create Single Base: Design one complete base structure
- Copy and Mirror: Duplicate base for perfect symmetry
- Team Assignment: Set appropriate team values for flags and homes
- Eyedropper Tool: Link flags to corresponding homes and vice versa
Flag System Polish
Section titled “Flag System Polish”Visual Feedback
Section titled “Visual Feedback”Enhance flag system with clear feedback:
- Team Colors: Blue flags for player team, red flags for enemy team
- Construction Script: Automatically set flag mesh based on team
- Status Indicators: Visual cues for flag states (home, carried, dropped)
Gameplay Balance
Section titled “Gameplay Balance”- Capture Requirements: Ensure your flag must be home to score
- Flag Reset: Dropped flags return home after timeout or ally touch
- Movement Penalties: Optional movement speed reduction for flag bearers
Multi-Game Mode Support
Section titled “Multi-Game Mode Support”- Flag Bearer Tracking: Boolean variable to identify flag carriers
- Game Mode Integration: Flags can be disabled for non-CTF game modes
- Team System: Leverages existing team framework for consistent behavior
The flag system creates engaging competitive gameplay with clear objectives, balanced mechanics, and immediate visual feedback for all player actions and game state changes.