I have a device that handles all gameplay logic for my game mode, and I have a storm controller in my level that I want to generate whenever something is triggered in that device. How do I add a custom event like what is seen in other creative devices?
Storm Controller
I want to be able to select an event from this dropdown which will then generate the storm.
Could you simply expose an event variable in your device and call Signal() on it when it is triggered? It might not be exactly the same, though it should have essentially the same functionality. An example is in the Space Inside / Escape Room showcase.
That fixed the error, thanks. However you can’t select it from the dropdown box from another device function. I am misunderstanding these events or is there something else I’m missing?
Storm Controller
You can’t create an editable storm controller variable so I can’t subscribe to it via Verse, only through these functions.
EDIT:
I am also getting this error when trying to signal the event
Unknown member `Signal` in `tuple()->event(tuple())`.(3506)
It would be nice if anyone can provide a fully working step by step example of how to use custom events and Signal() since we don’t fully understand how we should approach it.
The tutorial on creating a countdown timer shows you how you can set up events. In the tutorial you set up an event and signal it when the countdown ends.
From what I understand this functionality is not available. At least for now. You can create a custom event in your code, you can send it using Signal(), you can listen for it in any other custom device’s code using Await(), but you can’t access it from default creative devices (again, at least for now).
Thanks for that example @wxyz it wasnt exactly what i was having issues with but it put me on the path to find a work around so muchly appreciated!
Just to clarify because it maybe its still solvable without the workaround. As an example if i have an item spawner and i want to bind Enable() to an event on a custom creative device i can’t seem to do that as no events show up in the drop down.
This is my implementation of a player manager that listen to Spawn Pads and dispatch to subscribers…
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Simulation/Tags }
using { /UnrealEngine.com/Temporary/Diagnostics }
SpawnerTag := class(tag){}
players_subscribable_type := type{_(:agent):void}
players_subscribable := class:
var Subscribers<private>:[]players_subscribable_type = array{}
Subscribe<public>(Sub:players_subscribable_type):void =
set Subscribers += array{Sub}
Dispatch<public>(Player: agent):void =
for (Sub:Subscribers):
Sub(Player)
players_manager := class(creative_device):
var PlayerSpawners : []player_spawner_device = array{}
var Players : []agent = array{}
OnBegin<override>()<suspends>:void=
Print("Hello, Players!!")
# Get all the spawners
var TaggedSpawners : []creative_object_interface = 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)
OnPlayerSpawn(SpawnedPlayer : agent) : void =
Print("A Player just spawned!")
set Players = Players + array{SpawnedPlayer}
# Emit event for subscribers
PlayerSpawnedEvent.Dispatch(SpawnedPlayer)
# Custom event
var PlayerSpawnedEvent<public>:players_subscribable = players_subscribable{}