# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/using-npc-spawner-devices-in-unreal-editor-for-fortnite
# Local doc: epic-docs/documentation/en-us/fortnite/using-npc-spawner-devices-in-unreal-editor-for-fortnite.md
# Section: Using The NPC Spawner in Verse
using { /Fortnite.com/AI }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# Visit [here](../uefn/create-your-own-device-in-verse.md) to create a verse device.
# A Verse-authored creative device that can be placed in a level
npc_spawner_device_example := class(creative_device):
# Reference to the NPC Spawner Device in the level.
# In the Details panel for this Verse device,
# set this property to your NPC Spawner Device.
@editable
MyNPCSpawnerDevice:npc_spawner_device = npc_spawner_device{}
# Runs when the device is started in a running game.
OnBegin<override>()<suspends>:void=
# Example for subscribing to an event on the Creative device.
# Signaled when a character is spawned from the NPC Spawner Device.
# Sends the `agent` character who was spawned.
MyNPCSpawnerDevice.SpawnedEvent.Subscribe(OnCharacterSpawned)
# Signaled when a character Spawned from the NPC Spawner Device is
# eliminated. Sends a device_ai_interaction_result of the agent who eliminated
# the character, and
MyNPCSpawnerDevice.EliminatedEvent.Subscribe(OnCharacterEliminated)
# Spawn a character from the NPC Spawner Device.
MyNPCSpawnerDevice.Spawn()
Sleep(15.0)
# Eliminates all creatures spawned by this device.
Verse Library
verse
01 Using The Npc Spawner In Verse
Verse device managing NPC spawning, listening to spawn and elimination events, and despawning AI agents.
extracted-snippets/documentation/en-us/fortnite/using-npc-spawner-devices-in-unreal-editor-for-fortnite/01-using-the-npc-spawner-in-verse.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.