@editable
HideDuration : float = 2.0
# This function runs when the game starts.
OnBegin<override>()<suspends> : void =
# Find the Trigger device inside our Prefab by its tag.
if (Trigger := GetCreativeObjectsWithTag(tag_my_trigger{})[0],
TriggerDevice := trigger_device[Trigger]):
# Infinite loop: re-arms itself after every hide/show cycle.
loop:
# Block here until a player steps on the trigger.
Agent := TriggerDevice.TriggeredEvent.Await()
# Wait for the hide duration, then toggle visibility.
Sleep(HideDuration)
# Hide the parent prop (the platform itself).
Hide()
# Wait a moment before making it solid again.
Sleep(1.0)
# Show the platform again (collision re-enabled automatically).
Show()
GetCreativeObjectsWithTag
methodGetCreativeObjectsWithTag<native><public>(Tag: tag)<transacts>: []creative_object_interface
DEPRECATED - use `FindCreativeObjectsWithTag` instead. Returns an array containing all creative objects which have been marked with the specified `Tag`.
- Module
- /Fortnite.com/Devices
- Declared in
- Devices
- Source
- fortnite
Used in
# This runs when the component starts.
OnBegin<override>()<suspends> : void =
# We want to listen for players stepping on this object.
# We assume the Prefab has a Trigger Device tagged with tag_my_trigger.
# In the editor, add the tag "tag_my_trigger" to the Trigger device
# that is placed inside this Prefab.
if (Trigger := GetCreativeObjectsWithTag(tag_my_trigger{})[0],
TriggerDevice := trigger_device[Trigger]):
# This loop waits forever for a trigger event.
loop:
# Await fires each time a player steps on the trigger.
Agent := TriggerDevice.TriggeredEvent.Await()
# Wait a tiny bit so the player registers the step.
Sleep(0.1)
# Hide the platform (invisible + no collision).
Hide()
# Wait our set time before bringing it back.
Sleep(Delay)
# Bring it back (visible + collision restored).
Show()
# gameplay tag matches "PuzzleLight".
all_lights = GetCreativeObjectsWithTag(tag{"PuzzleLight"})
# Step 2: Start checking them
# We will look at each light in our list.
for (Light : all_lights):
# Step 3: Check the state
SampleVerse / Player Spawner Event
verse-source
var Players : []agent = array{}
OnBegin<override>()<suspends>:void=
Print("Hello, Players!!")
# Get all the spawners
var TaggedSpawners : []creative_object_interface = Verse.Scripts.Utils.GetCreativeObjectsWithTag(SpawnerTag{})
for (TaggedSpawner : TaggedSpawners, Spawner := player_spawner_device[TaggedSpawner]):
set PlayerSpawners = PlayerSpawners + array{Spawner}
# Subscribe to each player spawn pad
Spawner.SpawnedEvent.Subscribe(OnPlayerSpawn)
Utils / Tag Utils
verse-source
# Overloaded function to lookup a single tag and return an array of creative object interfaces
GetCreativeObjectsWithTag<public>(SearchTag: tag, ?Device: ?creative_device = false) : []creative_object_interface =
var ValidTaggedObjects: []creative_object_interface = GetCreativeObjectsWithTags(array{SearchTag}, ?Device:= Device)
return ValidTaggedObjects
AnimationSystem / Auto Animation Controller
verse-source
GetCreativeObjectsWithTag<private>(SearchTag:tag):[]creative_object_interface=
var ValidTaggedObjects: []creative_object_interface = array{}
TaggedObjects := Self.FindCreativeObjectsWithTag(SearchTag)
set ValidTaggedObjects = for:
TaggedObject : TaggedObjects
do:
TaggedObject
Logger.Print("Found {ValidTaggedObjects.Length} objects with tag")
return ValidTaggedObjects
NpcSystem / Vehicle Npc Behavior
verse-source
if (NPCAgent := GetNPCAgent[]):
NPCLocation := NPCAgent(1).GetTransform().Translation
# Find all creative objects with the tag "chair"
#ChairObjects := GetCreativeObjectsWithTag(bus_stop_tag{})
var ClosestChairDistance : float = 1000000.0 # Initialize with a large value
var ClosestChair : ?creative_object_interface = false
# Find the closest chair to the NPC
for (ChairObject : ChairObjects):
ChairLocation := ChairObject.GetTransform().Translation
DistanceToChair := Distance(NPCLocation, ChairLocation)
if:
DistanceToChair < ClosestChairDistance
set ClosestChairDistance = DistanceToChair
then:
set ClosestChair = option{ChairObject}
# If a closest chair is found
if (Chair := ClosestChair?):
# Navigate to the closest chair
NavigationTarget := MakeNavigationTarget(Chair.GetTransform().Translation)
NavigateResult := Navigatable.NavigateTo(NavigationTarget, ?MovementType := (/Fortnite.com/AI/movement_types:)Walking)
# Check if the navigation was successful
if (NavigateResult = navigation_result.Reached):
# Type cast the chair object to chair_device
if (ChairDevice := chair_device[Chair]):
# Tell the NPC to sit on the chair
race:
FocusOnChair := InFocus.MaintainFocus(Chair.GetTransform().Translation)
block:
Sleep(1.0)
ChairDevice.Seat(InAgent)
block:
Sleep(1.2)
PlayAnimation(AnimSeq_Sit)