Scene Graph `FindComponents` method is bugged

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Verse

Summary

FindComponents is bugged. It does not return expected results.

Steps to Reproduce

Add multiple components to an entity, including custom verse components.

verse_component := class(component) {}

test_query_component<public> := class(verse_component) {
  @editable
  Name: string = ""

  OnBeginSimulation<override>(): void = {
    (super:)OnBeginSimulation()
    Print("{Name} test_query_component OnBeginSimulation")
  }

  OnSimulate<override>()<suspends>: void = {
    Print("{Name} test_query_component OnSimulate")
    Sleep(2.0)
    Components := Entity.FindComponents(component)
    Print("components {Components.Length}")
    for (C: Components) {
      if (A := test_query_component[C]) {
        Print("is test_query_component")
      } else if (A := test_order_component[C]) {
        Print("is test_order_component")
      } else if (A := test_sg_component[C]) {
        Print("is test_sg_component")
      } else if (A := transform_component[C]) {
        Print("is transform_component")
      } else if (A := mesh_component[C]) {
        Print("is mesh_component")
      }
    }

    VCs := Entity.FindComponents(verse_component)
    Print("verse components {VCs.Length}")

    for (C: VCs) {
      if (A := test_query_component[C]) {
        Print("is test_query_component")
      } else if (A := test_order_component[C]) {
        Print("is test_order_component")
      } else if (A := test_sg_component[C]) {
        Print("is test_sg_component")
      } else if (A := transform_component[C]) {
        Print("is transform_component")
      } else if (A := mesh_component[C]) {
        Print("is mesh_component")
      }
    }

    TestQ := Entity.FindComponents(test_query_component)
    Print("test_query_component {TestQ.Length}")
  }
}

Expected Result

The components returned should be totally different.

  • Entity.FindComponents(verse_component) should yield a list of all components, not just one. In my case 6 components.
  • Entity.FindComponents(verse_component) should yield 3 components (all custom verse components).

Observed Result

[2024.06.13-21.20.48:850][601]LogVerse: : components 1 :x: (should be 6)
[2024.06.13-21.20.48:850][601]LogVerse: : is transform_component
[2024.06.13-21.20.48:850][601]LogVerse: : verse components 1 :x: (should be 3)
[2024.06.13-21.20.48:850][601]LogVerse: : is test_order_component
[2024.06.13-21.20.48:850][601]LogVerse: : test_query_component 1

Platform(s)

PC

The status of FORT-757703 incident has been moved from ‘Needs Triage’ to ‘Closed’. Resolution Reason: ‘Fixed’

Thank you, the team is taking a look.

1 Like

According to the documentation, some of this behavior is not a bug.

Currently UEFN will not allow you to add more than one component of a given subclass of component (for example, only one type of light_component). This restriction will be relaxed in the future where components will be able to decide if they wish to allow only one instance or many instances of the same component to existtogether on one entity.

This is incorrect and you’re reading the report wrong. Fetching over a common super type should yield multiple results unless there is really only one or none component that would be a subtype of the requested component type. Requesting components over component should always yield all attached components, but it currently doesn’t, which is clearly a bug.