Blocker - Custom device's local variables are reset when called from another device.

  • Device1 changes a local variable in OnBegin or anytime.
  • From a trigger callback, Device2 calls a method on Device1.
  • In the Device1’s method, the local variable is now reset to default values.

Can a custom device not reference another custom device?
Its almost as if Device2 has a completely different instance reference of Device1.

Is this not the proper way to do something like this?

This seems like a major bug when trying to communicate between custom devices and is currently a major blocker for us.

Output log:

LogVerse: log_test1_device: ----------------
LogVerse: log_test1_device: _testfloat: 0.123457
LogVerse: log_test1_device: _testfloat: 0.000000

Example Device1:

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /EpicGames.com/Temporary/Diagnostics }

log_test1_device := class(log_channel){}

test1_device := class(creative_device):
    Logger:log = log{Channel:=log_test1_device}

    var _testfloat:float = 0.0

    OnBegin<override>()<suspends>:void=
        set _testfloat = 0.123456789
        Logger.Print("----------------")
        Logger.Print("_testfloat: {_testfloat}")

    TestCall():void=
        Logger.Print("_testfloat: {_testfloat}")

Example Device 2:

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /EpicGames.com/Temporary/Diagnostics }

test2_device := class(creative_device):

    @editable
    Test1Device : test1_device = test1_device{}

    @editable
    TestTrigger : trigger_device = trigger_device{}

    OnBegin<override>()<suspends>:void=
        TestTrigger.TriggeredEvent.Subscribe(OnTriggeredEvent)

    OnTriggeredEvent(Player:player):void=
        Test1Device.TestCall()

I am also seeing this. With one device that randomly sets an int on trigger and prints it on another trigger it works fine. When I add a second device that calls print via its own trigger all the values are default.


using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using {/Verse.org/Random }
using { /EpicGames.com/Temporary/Diagnostics }

simple_data_device := class(creative_device)
{
    @editable DisplayValueTrigger:trigger_device = trigger_device{}
    @editable SetRandomValueTrigger:trigger_device = trigger_device{}

    var Value:int = -1
    OnBegin<override>()<suspends>:void=
    {
        DisplayValueTrigger.TriggeredEvent.Subscribe(OnDisplayData)
        SetRandomValueTrigger.TriggeredEvent.Subscribe(OnSetDataRandomly)
    }

    OnSetDataRandomly(TriggerPlayer:player):void=
    {
        set Value = GetRandomInt(0, 100);
        Print("Set Value: {Value}")  
    }

    OnDisplayData<public>(TriggerPlayer:player):void=
    {
        Print("Current Value: {Value}")    
    }
}

    

Second device referencing this one.


using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /EpicGames.com/Temporary/Diagnostics }


simple_secondary_device := class(creative_device)
{
    @editable 
    SimpleDataDevice:simple_data_device=simple_data_device{}

    @editable DisplayValueSecondaryTrigger:trigger_device = trigger_device{}


    OnBegin<override>()<suspends>:void=
    {
        DisplayValueSecondaryTrigger.TriggeredEvent.Subscribe(OnDisplayDataSecondary)
    }

    OnDisplayDataSecondary<public>(TriggerPlayer:player):void=
    {
        Print("Calling DisplayData Through Secondary Device...")
        SimpleDataDevice.OnDisplayData(TriggerPlayer)     
    }
}

    

Thanks both, our team is taking a look.

1 Like

While waiting for this fix to reach release it should be possible to workaround this issue by using a one element array rather than the direct reference.

Could you try changing your code from

@editable
Test1Device : test1_device = test1_device{}

To:

@editable
Test1Device : []test1_device = array{}

and adding a single element with the device reference in the editor.

This temp fix works, thank you!

Our current fix has been to use trigger devices as a way to signal events between custom devices. Not ideal, as you can’t pass any additional information.

Also in the future we would like to have the ability to create custom listenable events on our devices if possible.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /EpicGames.com/Temporary/Diagnostics }

test2_device := class(creative_device):

    @editable
    Test1Devices : []test1_device = array{}

    @editable
    TestTrigger : trigger_device = trigger_device{}

    OnBegin<override>()<suspends>:void=
        TestTrigger.TriggeredEvent.Subscribe(OnTriggeredEvent)

    OnTriggeredEvent(Player:agent):void=
        for(X -> Device : Test1Devices):
            Device.TestCall()

This is still not working in 23.50.

1 Like

Confirming this is still an issue, confirming the workaround does work

Also confirming that this is still an issue, but the workaround works fine for me.

Custom device to custom device method calls without resetting locally scoped properties is now working in v24.0

This appears to still be an issue in 24.01, along with more issues.

Here is a test project with two test devices that reference each other and call a method from one device to another.
Test11.zip (279.8 KB)

Super strange, when I set the device reference in the array on test2_device, then push changes up, the device is removed from my level?!

No properties set on either device:

Set properties on devices and test2_device disappears:

Zero Verse errors, zero Asset Check fails.

test1_device:
Screenshot (67)

test2_device:
Screenshot (68)

1 Like

There was an issue with circular references between devices which like you said, leads to one of the devices disappearing. This should be fixed in a later release.

Individual non-circular references from one custom device to another should still work fine in the mean time.

1 Like