# Source URL: https://dev.epicgames.com/documentation/fortnite/verse-parkour-template-in-unreal-editor-for-fortnite
# Local doc: epic-docs/documentation/fortnite/verse-parkour-template-in-unreal-editor-for-fortnite.md
# Section: Reset the Timer Device to ensure respawning players get the full amount of time
# Function that is called when a battery item is picked up from the Item Spawners
HandleBatteryPickedUp(Agent:agent):void=
# Increment the number of batteries collected
set BatteriesCollected = BatteriesCollected + 1
# This is how you can output the number of batteries to the log. Useful for debugging
Logger.Print("Number of batteries picked up: {BatteriesCollected}")
# Check to see if there are enough batteries collected to the end the game
if:
BatteriesCollected >= BatteryItemSpawners.Length
then:
# Check to see if we've collected 4 (or more) batteries. If so, we have won, call the EndGame function
spawn { EndGame(Agent) }
else:
# This code runs if the number of batteries is less than 4. Show a Hud Message to spur the player on
# HUD message is "battery" if only 1 battery is collect. Becomes "batteries" if more than 1 is collected
if:
BatteriesCollected = 1
then:
HUDMessageBattery.SetText(BatteryCollectedMessage(BatteriesCollected))
HUDMessageBattery.Show(Agent)
else:
HUDMessageBattery.SetText(BatteriesCollectedMessage(BatteriesCollected))
HUDMessageBattery.Show(Agent)
# Then we get the next Item Spawner in our array we set up
# We do this by "indexing" into the array. It is inside the "if" statement to ensure that NextBatterySpawner is referenced correctly
Verse Library
verse
04 Reset The Timer Device To Ensure Respawning Player
Manages battery collection by tracking progress, checking win conditions, and displaying contextual HUD feedback.
extracted-snippets/documentation/fortnite/verse-parkour-template-in-unreal-editor-for-fortnite/04-reset-the-timer-device-to-ensure-respawning-player.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.