Casting Entity to Player or Agent Fails

Summary

When a player overlaps with a mesh_component expect the entity that returns can be casted to Player or Agent.

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

  1. Create Blank Project.
  2. Activate scene graph beta on project settings.
  3. Add an empty entity.

This next steps are necessary to avoid another bug that with mesh_components of basic shapes from UEFN deactivating the collision check from it, keeps colliding.

  1. Create a cube with modeling tools.
  2. Add collisions to static mesh and set collision to overlap all
  3. Add new mesh created to entity.
  4. Uncheck Collidable option from it.
  5. Add and script to debug this collisions in my case volume_component
  6. Test in a Session

Expected Result

Entity cast to succeed being a player or agent

Observed Result

Entity cast fails for both agent and player

Platform(s)

UEFN, PC

Upload an image




Video

Additional Notes

using { /Verse.org }
using { /Verse.org/Native }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
using { /Fortnite.com/Playspaces }

volume_component := class<final_super>(component):

var Subscriptions :[]cancelable = array{}

OnBeginSimulation<override>():void =
    (super:)OnBeginSimulation()
    if(MeshComp := Entity.GetComponent[mesh_component]):
       EntityEnterResult := MeshComp.EntityEnteredEvent.Subscribe(OnEntityEnteredVolume)
       EntityExitResult := MeshComp.EntityExitedEvent.Subscribe(OnEntityExitedVolume)
       set Subscriptions += array { EntityEnterResult }
       set Subscriptions += array { EntityExitResult }

OnEndSimulation<override>():void=
    (super:)OnEndSimulation()
    for(Sub:Subscriptions):
        Sub.Cancel()

OnEntityEnteredVolume(EnteredEntity:entity):void=
    CheckEntityWithRoundManager("[OnEntered]",EnteredEntity)

    if(Agent := agent[EnteredEntity]):
        Print("[OnEntered] Casting [EnteredEntity] to [Agent] succeded")
    else:
        Print("[OnEntered] Casting [EnteredEntity] to [Agent] failed")

    if(Player:= player[EnteredEntity]):
        Print("[OnEntered] Casting [EnteredEntity] to [Player] succeded")
    else:
        Print("[OnEntered] Casting [EnteredEntity] to [Player] failed")

OnEntityExitedVolume(ExitedEntity:entity):void=
    CheckEntityWithRoundManager("[OnExited]", ExitedEntity)

    if(Agent := agent[ExitedEntity]):
        Print("[OnExited] Casting [ExitedEntity] to [Agent] succeded")
    else:
        Print("[OnExited] Casting [ExitedEntity] to [Agent] failed")

    if(Player:= player[ExitedEntity]):
        Print("[OnExited] Casting [ExitedEntity] to [Player] succeded")
    else:
        Print("[OnExited] Casting [ExitedEntity] to [Player] failed")

CheckEntityWithRoundManager(Prefix:string, EntityToCheck:entity):void=
    if:
        Playspace := Entity.GetPlayspaceForEntity[]
        Players := Playspace.GetPlayers()
    then:
        for(Player : Players):
            if:
                PlayerEntity := entity[Player]
            then:
                Print("{Prefix} Player to entity cast succeded")
                if:
                    EntityToCheck = PlayerEntity
                then:
                    Print("{Prefix} Entity is a player")
                    return
        Print("{Prefix} Entity was not a player")

Found this

1 Like

Hi! Thanks for the quick reply, just tested it and it does work, Thanks! it’s a nice workaround to this problem

1 Like

Its still bugged tho clearly so this should be left open until its fixed

Yeah I will leave it open.

Thanks again! this unblocked a really big problem on the idea I was testing.

1 Like