-
Notifications
You must be signed in to change notification settings - Fork 0
Step 3: Time Limit Guide
Time Limit system provides stage time limits and endless mode support for Vampire Survivors-style roguelike games.
- ✅ Configurable time limit (default: 30 minutes)
- ✅ Endless mode (unlimited game duration)
- ✅ Blueprint events (OnTimeLimitReached, OnGameTimeUpdated)
- ✅ Runtime changeable (SetEndlessMode, SetTimeLimit)
- ✅ UI-friendly (events for timer display)
Add Game Director actor to level and configure:
Time Limit:
✓ Endless Mode: false (time limit active)
✓ Time Limit: 1800.0 (30 minutes = 30 * 60 = 1800 seconds)
Time Limit Examples:
- 15 minutes: 900.0 seconds
- 20 minutes: 1200.0 seconds
- 30 minutes: 1800.0 seconds (default)
- 45 minutes: 2700.0 seconds
In Game Mode or Player Controller Blueprint:
Event BeginPlay
↓
Get Actor of Class (URFGameDirector)
↓
Bind Event to OnTimeLimitReached
↓
[Custom Event: Handle Time Limit Reached]
Input: Total Game Time (float)
↓
Show "Time's Up!" message
↓
Trigger end game sequence
To display timer in Widget Blueprint:
Event Construct
↓
Get Actor of Class (URFGameDirector)
↓
Bind Event to OnGameTimeUpdated
↓
[Custom Event: Update Timer Display]
Input: Current Time (float), Time Remaining (float)
↓
Format Time (MM:SS)
↓
Set Text (Timer Text Block)
Easy UI functions provide access to timer information without finding Game Director reference.
Returns current game time in seconds.
Get Current Game Time (Easy UI)
↓
Returns: 1250.5 (seconds)
Returns remaining time in seconds.
Get Time Remaining (Easy UI)
↓
Returns: 549.5 (seconds) or -1.0 (endless mode)
Has time limit been reached?
Is Time Limit Reached (Easy UI)
↓
Returns: true/false
Is endless mode active?
Is Endless Mode (Easy UI)
↓
Returns: true/false
Returns complete timer display string (ready for UI).
Get Timer Display String (Easy UI)
↓
Returns: "20:50 / 30:00" or "20:50 (Endless)"
Converts seconds to MM:SS format.
Format Game Time (Easy UI)
└─ Time In Seconds: 125.5
↓
Returns: "02:05"
Enables/disables endless mode.
Set Endless Mode (Easy UI)
└─ Enabled: true
↓
Returns: true (success) / false (director not found)
Changes time limit.
Set Time Limit (Easy UI)
└─ New Time Limit: 1200.0 (20 minutes)
↓
Returns: true (success) / false (director not found)
Endless Mode (bool)
-
false: Time limit active (default) -
true: Unlimited game duration
Time Limit (float)
- Time limit in seconds
- Minimum: 60.0 seconds
- Default: 1800.0 seconds (30 minutes)
- Only visible when Endless Mode = false
Change settings at runtime in Blueprint:
// Enable endless mode
Get Game Director
↓
Set Endless Mode (true)
// Change time limit (20 minutes)
Get Game Director
↓
Set Time Limit (1200.0)
Endless mode allows game to continue indefinitely without time limit.
Features:
- No time limit
- OnTimeLimitReached event never triggers
- GetTimeRemaining() returns -1
- Waves continue infinitely
Time Limit:
✓ Endless Mode: true
Get Game Director
↓
Set Endless Mode (true)
Display endless mode in timer UI:
Event: Update Timer Display
Input: Current Time, Time Remaining
↓
Branch: Time Remaining == -1?
├─ True: (Endless Mode)
│ ↓
│ Format Text ("Time: {0} (Endless)")
│ └─ {0}: Current Time (MM:SS)
│ ↓
│ Set Text (Timer Text)
└─ False: (Normal Mode)
↓
Format Text ("Time: {0} / {1}")
├─ {0}: Current Time (MM:SS)
└─ {1}: Time Remaining (MM:SS)
↓
Set Text (Timer Text)
Triggered when time limit reached (only when Endless Mode = false).
Event: On Time Limit Reached
Input: Total Game Time (float)
↓
Show "Time's Up!" notification
↓
Play sound effect
↓
Trigger end game sequence
↓
[Optional] Spawn Reaper enemy
Usage Scenarios:
- Show game over screen
- Spawn Reaper enemy (Vampire Survivors style)
- Give bonus gold (500 gold)
- Save statistics
Triggered every second (for timer UI).
Event: On Game Time Updated
Input: Current Time (float), Time Remaining (float)
↓
Format Current Time (MM:SS)
↓
Format Time Remaining (MM:SS)
↓
Update Timer UI
↓
[Optional] Change color if time < 60 seconds (red warning)
Usage Scenarios:
- Timer UI update
- Last minute warning (red color)
- Sound effect (last 10 seconds countdown)
Event Tick:
Event Tick
↓
Get Timer Display String (Easy UI)
↓
Set Text (Timer Text)
Advantages:
- ✅ Single line of code
- ✅ No Game Director reference needed
- ✅ Automatic formatting
Disadvantages:
⚠️ Runs every frame (performance)
Event Construct:
Event Construct
↓
Get Actor of Class (URFGameDirector)
↓
Bind Event to OnGameTimeUpdated
↓
[Custom Event: Update Timer]
Custom Event: Update Timer
Input: Current Time (float), Time Remaining (float)
↓
Format Game Time (Easy UI)
└─ Time In Seconds: Current Time
↓
Set Text (Current Time Text)
↓
Branch: Time Remaining < 0?
├─ True: Set Text "Endless"
└─ False: Format and Set Remaining Time
Advantages:
- ✅ Updates only once per second
- ✅ Performance-friendly
- ✅ Event-driven
Change color as time decreases:
Function: Get Timer Color
Input: Time Remaining (float)
↓
Branch: Time Remaining < 60?
├─ True: Return Red (warning)
├─ Time Remaining < 300? (5 min)
│ └─ Return Orange (caution)
└─ Else: Return White (normal)
Goal: Spawn Reaper after 30 minutes, player tries to escape.
Game Director Settings:
Endless Mode: false
Time Limit: 1800.0 (30 minutes)
Blueprint (Game Mode):
Event: On Time Limit Reached
Input: Total Game Time
↓
Show Notification ("The Reaper has arrived!")
↓
Play Dramatic Sound
↓
Spawn Actor (BP_Reaper)
└─ Location: Near Player
Goal: Player plays as long as desired, no time limit.
Game Director Settings:
Endless Mode: true
Blueprint (UI Widget):
Event: Update Timer
Input: Current Time, Time Remaining
↓
Branch: Time Remaining == -1?
├─ True: Format Text ("Time: {0} (Endless)")
└─ False: Format Text ("Time: {0} / {1}")
Goal: Each stage has different time limit.
Stage Selection Blueprint:
On Stage Selected
Input: Stage ID (int)
↓
Get Game Director
↓
Switch on Stage ID:
├─ Case 0: Set Time Limit (600.0) // 10 min
├─ Case 1: Set Time Limit (1200.0) // 20 min
├─ Case 2: Set Time Limit (1800.0) // 30 min
├─ Case 3: Set Time Limit (2700.0) // 45 min
└─ Case 4: Set Endless Mode (true)
Goal: Warn player in last 60 seconds.
Blueprint (UI Widget):
Event: Update Timer
Input: Current Time, Time Remaining
↓
Branch: Time Remaining < 60 AND Time Remaining > 0?
├─ True: Set Text Color (Red) + Play Animation (Flash)
└─ False: Set Text Color (White)
Problem: Timer not visible in UI.
Solutions:
-
Is event binding done?
- Bound to OnGameTimeUpdated event?
- Check binding code in Event Graph
-
Does Game Director exist?
- Is URFGameDirector actor in level?
- Is Get Actor of Class successful?
Problem: OnTimeLimitReached event not working.
Solutions:
-
Is Endless Mode off?
- Game Director Endless Mode must be false
- Was SetEndlessMode(false) called at runtime?
-
Is Time Limit correct?
- Time Limit must be > 0
- CurrentGameTime must be >= TimeLimit
-
Is event binding done?
- Bound to OnTimeLimitReached event?
Problem: Endless Mode active but time limit still exists.
Solutions:
-
Is Endless Mode active?
- Game Director Endless Mode must be true
- IsEndlessMode() should return true
-
Is UI updated?
- Does GetTimeRemaining() return -1?
- Does UI show endless mode display?
Pickups that add time:
Event: On Pickup Collected (Time Bonus)
Input: Bonus Time (float)
↓
Get Game Director
↓
Branch: Is Endless Mode?
├─ True: Skip (no effect in endless)
└─ False:
↓
Get Time Limit
↓
Set Time Limit (Current + Bonus Time)
↓
Show Notification ("+30 seconds!")
Spawn Reaper every minute after time limit:
Event: On Time Limit Reached
↓
Set Timer by Function Name
└─ Function: Spawn Reaper
└─ Time: 60.0 (every minute)
└─ Looping: true
If you encounter issues:
- Enable debug logging (Game Director)
- Check Output Log
- Verify event bindings
- Check GetTimeRemaining() value
Note: This system is optimized for Vampire Survivors-style roguelike games.