Accessing Agent from SucceededEvent in interactable_component disconnects from Fortnite

Summary

Accessing the agent in response to SucceededEvent in interaction_component causes session disconnect.

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Scene Graph

Steps to Reproduce

  1. Create a new Verse class based on interactable_component. Create a callback to subscribe to SucceededEvent, and access the Agent param.
dm_interaction<public> := class<final_super>(interactable_component):
    OnSucceeded(Agent:agent):void=
        Print("Succeeded.")
    
        if (FortChar := Agent.GetFortCharacter[]):
            DebugDraw := debug_draw{}
            DebugDraw.DrawSphere(
                FortChar.GetGlobalTransform().Translation, 
                ?DrawDurationPolicy := debug_draw_duration_policy.FiniteDuration, 
                ?Color := NamedColors.Red,
                ?Duration := 10.0)
  
    OnBeginSimulation<override>():void =
        (super:)OnBeginSimulation()
        SucceededEvent.Subscribe(OnSucceeded)

Fornite session will disconnect, unable to reconnect without closing both Fortnite and UEFN.

[Update]

So it turns out that calling DrawSphere from within the SucceededEvent (either in a callback or using Await) results in overload resolution of the DrawSphere overload that takes the vector3 from the old coordinate system (UnrealEngine.org/Temporary/SpatialMath) despite a value being passed in from the new coordinate system (Verse.org/SpatialMath). Due to both overloads existing in debug_draw, passing in either one results in no compilation errors, but the actual overload resolved was the wrong one. Creating a vector from the old coordinate system and passing that in results in the desired result. This is however unexpected behavior still, as overload resolution chooses the wrong overload when passing in a vector3 from Verse.org.SpatialMath while in the SucceededEvent only. The following code compiles and runs as expected (aside from the fact that you must pass in the old vector3 type)
```

OnSimulate<override>()<suspends>:void= 

    Agent := SucceededEvent.Await()



    if (FortChar := Agent.GetFortCharacter\[\]):

        FortTransform := FortChar.GetGlobalTransform()

        Translation := FortTransform.Translation



        DrawLocation := vector3{X:= Translation.Forward, Y:= -Translation.Left, Z:= Translation.Up}

        DebugDraw.DrawSphere(

            DrawLocation, 

            ?DrawDurationPolicy := debug_draw_duration_policy.FiniteDuration, 

            ?Color := NamedColors.Red,

            ?Duration := 600.0,

            ?Radius := 50.0)

```

[Second Update]

Upon further investigation, the disconnect behaves sporadically, even with the above fix. There seems to be a problem when accessing and using the Agent in the SucceededEvent.

I have found however that creating a suspends functin that sleeps for a single tick before accessing the agent appears to work consistently.

    OnAgentInteract(Agent:agent)<suspends>:void=
        Sleep(0.0)
        # Use agent here...

    OnSucceeded(Agent:agent):void=
        spawn. OnAgentInteract(Agent)

    OnSimulate<override>()<suspends>:void=
        SucceededEvent.Subscribe(OnSucceeded)

There appears to be no unintended effects when accessing and using the agent on the next tick in this manner.

Expected Result

The Agent should be valid in callbacks subscribed to SucceededEvent.

Observed Result

Upon interacting with an entity with the interactable_component, the session is disconnected.

Platform(s)

windows

We’ll get someone to take a look.

1 Like

It’s better to wait a bit. The bug was being discussed on The Lab Discord server, and the issue seems to be with the LUF variant of DebugDraw.DrawSphere.

Edit: It’s already updated. :+1:

Yes to be clear, my original title for this report assumed the problem was with Agent not being a valid agent object, but that was incorrect. The issue was actually with incorrect overload resolution of DebugDraw.

1 Like

Edited my original report with additional findings.

FORT-1130875 is now ‘In Progress’! Our team is actively working on it!