In this step, you will create a special target that awards extra time when a player hits it. The target pops up randomly when hitting positive scoring targets, and the odds that it will pop up increase until it appears.
Modify Your Island
Select the Combo Target in the viewport.
Press the Alt key, then left-click the axis widget, and drag a duplicate target to the front of your shooting gallery. This is the bonus time target.
In the Details panel, set the TargetType to Dancing.
Write Verse Code
This page guides you step by step through the code changes, but if you want to check your work, review the Complete Code section for the final result.
Open the
shooting_range_manager_device.versefile.Add the following library to support random number generation.
Verseusing { /Verse.org/Random }Add the following variables to store the target device reference and related properties. The time duration and reward variables are in seconds.
Verse@editable InitialTimerDuration:float = 30.0 @editable MaxTimerDuration:float = 60.0 @editable BonusTimeTarget:shooting_range_target_track_device = shooting_range_target_track_device{} @editableAdd the
OnBonusTimeTargetHitcallback method that increases the timer.Verse# A hit callback that adds bonus time and disables the BonusTimeTarget. OnBonusTimeTargetHit():void= CurrentDuration:float = Timer.GetActiveDuration() Timer.SetActiveDuration(CurrentDuration + BonusTimeReward) BonusTimeTarget.PopDown() BonusTimeTarget.Disable()Modify the
OnBeginmethod to set up the bonus time target event subscription and disable it.Verse# Runs when the device is started in a running game. OnBegin<override>()<suspends>:void= # Subscribing to the GoodTarget HitEvents. GoodTarget1.HitEvent.Subscribe(OnGoodTarget1Hit) GoodTarget2.HitEvent.Subscribe(OnGoodTarget2Hit) GoodTarget3.HitEvent.Subscribe(OnGoodTarget3Hit) # Subscribing to the BadTarget HitEvents. BadTarget1.HitEvent.Subscribe(OnBadTarget1Hit) BadTarget2.HitEvent.Subscribe(OnBadTarget2Hit)Modify the
StartTimermethod to set the timer's maximum and active durations.Verse# Setup and start the timer. StartTimer():void= # Set the event subscription to call OnTimerSuccess when the timer finishes. Timer.SuccessEvent.Subscribe(OnTimerSuccess) <# --- New Code Start --- #> # Set the max and active duration based on the set property values. Timer.SetMaxDuration(MaxTimerDuration) Timer.SetActiveDuration(InitialTimerDuration)Modify the
AdjustScoremethod to randomly make the bonus time target appear based on how many Good Targets you hit.Verse# Adjusts the player's score by the provided value. AdjustScore(Value:int):void= # Start the timer if it hasn't started yet. if (not IsTimerStarted?): StartTimer() # Sets the score award to the base value of the target. ScoreManager.SetScoreAward(Value) # Gets the first player in the playspace.Save and build your Verse code.
Complete Code
using { /Fortnite.com/Devices }
using { /Verse.org/Random }
using { /Verse.org/Simulation }
# A device that manages shooting range gameplay.
shooting_range_manager_device := class(creative_device):
@editable
ScoreManager:score_manager_device = score_manager_device{}
Bring It Together
Select the shooting_range_manager_device in the viewport or Outliner panel.
In the Details panel, set BonusTimeTarget to the bonus time target.
Push your changes and playtest your island.
Verify that the bonus time target appears occasionally after shooting positive scoring targets.