# Fire custom event to another creative devices?

**URL:** <https://forums.unrealengine.com/t/fire-custom-event-to-another-creative-devices/1401721>\
**Category:** Programming & Scripting\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, fortnite\
**Created:** [November 18, 2023, 9:01pm UTC](https://forums.unrealengine.com/t/fire-custom-event-to-another-creative-devices/1401721 "2023-11-18T21:01:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dwey](https://forums.unrealengine.com/u/dwey)\
**Post date:** [November 18, 2023, 9:01pm UTC](https://forums.unrealengine.com/t/fire-custom-event-to-another-creative-devices/1401721/1 "2023-11-18T21:01:24Z")

</div>

I want one device to fire an event when the velocity of a player change more than a set value and another device to receive the event fired.

I tried some solutions from here but I don’t quite understand the right way to do it.

> [@How do I add custom events in verse creative devices?](https://forums.unrealengine.com/t/how-do-i-add-custom-events-in-verse-creative-devices/824922):
>
> 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 [image] I want to be able to select an event from this dropdown which will then generate the storm. Score Manager Example Verse (Digest script): MaxTriggers\<public\>:listenable(agent) = external {} Verse (Custom creative dev…

The device receiving the event:

```auto
using { /Fortnite.com/Devices }

test_device := class(creative_device):
   
    VelocityTrackerDevice : vel_tracker_device = vel_tracker_device{}
  
    OnBegin<override>() : void =
        # MY EVENT
        VelocityTrackerDevice.CustomEvent_Velocity.Subscribe(ImSubscribed)

    
    ImSubscribed(result : float ): void = {
            Print("Velocity event -> {result}")
    }
    

```

The device firing the event:

```auto
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary }
using { /Verse.org/Concurrency }
using { /Fortnite.com/Characters }

# THESE COSTUM EVENT CLASSES ARE FROM THE LINK ABOVE

custom_cancelable<public> := class:
    var Canceled : logic = false

    CancelEvent : event() = event(){}

    Cancel():void=
        set Canceled = true
        CancelEvent.Signal()

custom_subscribable<public>(t:type)<computes> := class<public>(awaitable(t)):

    InnerEvent : event(t) = event(t){}

    Subscribe(Callback:type {__(:t):void}):custom_cancelable=
        Cancelable := custom_cancelable{}
        spawn{_WaitForEvent(Callback, Cancelable)}

        Cancelable

    _WaitForEvent(Callback:type {__(:t):void}, Cancelable: custom_cancelable)<suspends>:void=
        race:
            # Wait for payload to be sent
            loop:
                Payload := InnerEvent.Await()

                # Just in case
                if(not Cancelable.Canceled?):
                    Callback(Payload)
                else:
                    break # Just in case

            # Cancelable got canceled
            Cancelable.CancelEvent.Await()

    
    Signal<public>(Payload:t):void =
        InnerEvent.Signal(Payload)

    Await<override>()<suspends>:t=
        InnerEvent.Await()

# DEVICE TO TRACK PLAYERS VELOCITY
vel_tracker_device := class<concrete>(creative_device):
    var PlayersLastPositionAndRotation : [agent]tuple(vector3, rotation) = map{} 
    var PlayersVelocity : [agent]tuple(vector3, float) = map{}

    # MY EVENT
    var CustomEvent_Velocity<public> : custom_subscribable(float) = custom_subscribable(float){}
 

    @editable
    DeltaTime : float = 0.0333 
    @editable
    DeltaVelocitySignal : float = 2.0
    
    OnBegin<override>()<suspends>:void=
        spawn:
            UpdatePlayersVelocity()

    UpdatePlayersVelocity<internal>()<suspends>:void=
        loop:
            for(i := 0..GetPlayspace().GetPlayers().Length-1, PlayerAgent := GetPlayspace().GetPlayers()[i]):
                if(CFortChar := PlayerAgent.GetFortCharacter[], CFortChar.IsActive[]):
                    CurrentPositionCharacter := CFortChar.GetTransform().Translation
                    CurrentRotationCharacter := CFortChar.GetViewRotation()
                    if(LastPosition := PlayersLastPositionAndRotation[PlayerAgent](0), LastRotation := PlayersLastPositionAndRotation[PlayerAgent](1), set PlayersVelocity[PlayerAgent] = ((CurrentPositionCharacter - LastPosition) / DeltaTime, (CurrentRotationCharacter.GetYawPitchRollDegrees()[0] - LastRotation.GetYawPitchRollDegrees()[0]) / DeltaTime), set PlayersLastPositionAndRotation[PlayerAgent] = (CurrentPositionCharacter, CurrentRotationCharacter)):
                                        if (AmountChanged : float = Distance(LastPosition, CurrentPositionCharacter) > DeltaVelocitySignal):

 #I WANT THIS EVENT TO FIRE TO ANOTHER DEVICE 
                                            CustomEvent_Velocity.Signal(AmountChanged)
                                        
                    else if(set PlayersLastPositionAndRotation[PlayerAgent] = (CurrentPositionCharacter, CurrentRotationCharacter)):                        
                else:
                    if(set PlayersVelocity[PlayerAgent] = (vector3{}, 0.0)):
            Sleep(DeltaTime)

```
