Hello,
I’m relatively new to UEFN and a beginner in Verse. I’ve been trying to set up the Random Number Generator to trigger a random trigger after success with the Timer Device. However, the Random Number Generator only works once and then bugs out, which is why need to turn to Verse. As mentioned before, I have no experience with Verse and hope to get some support here. Best regards.
nevermind guys, I figured it out:
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Verse.org/Random }
This device selects randomly between three trigger devices when a timer succeeds
random_trigger_controller := class(creative_device):
@editable
TimerDevice : timer_device = timer_device{}
@editable
TriggerDevice1 : trigger_device = trigger_device{}
@editable
TriggerDevice2 : trigger_device = trigger_device{}
@editable
TriggerDevice3 : trigger_device = trigger_device{}
# Called when the device is started in game
OnBegin<override>()<suspends> : void =
# Subscribe to the timer's success event
TimerDevice.SuccessEvent.Subscribe(OnTimerSuccess)
# This function is called when the timer succeeds
OnTimerSuccess(Agent:?agent) : void =
# Create a random generator and get a number between 1 and 3
RandomChoice:int = GetRandomInt(1,3)
# Trigger one of the three devices based on the random number
if (RandomChoice = 1):
TriggerDevice1.Trigger()
else if (RandomChoice = 2):
TriggerDevice2.Trigger()
else:
TriggerDevice3.Trigger()
leaving it if others need it.
1 Like
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.