When a dynamically created entity switches parent, its child entities and components are broken.

Summary

A new Scene Graph issue: Prefabs in Assets.digest function normally after being added via entity.AddEntities(). However, after reusing the same PrefabEntity via entity.AddEntities() to change its parent entity, the PrefabEntity, its child entities, and components stop working - modifications like changing child entity scales or mesh visibility (IsVisible) take no effect. This problem hadn’t occurred before V39.30.

Please select what you are reporting on:

Unreal Editor for Fortnite

What Type of Bug are you experiencing?

Other

Steps to Reproduce

  1. Create a Prefab with mesh and interactable component. Add a child entity with mesh. The interactable component toggles the child’s IsVisible state.
mesh_enable_component<public> := class<final_super>(component):

    @editable
    SubEntity: entity = entity{}

    var IsVisible: logic = false
    var InteractedCount: int = 0

    OnSimulate<override>()<suspends>: void =
        if (InteracteComp := Entity.GetComponent[interactable_component]):
            InteracteComp.SucceededEvent.Subscribe(OnInteracted)

    OnInteracted(Agent: agent): void =
        if (MeshComp := SubEntity.GetComponent[mesh_component]):
            set InteractedCount += 1
            Print("User has interacted {InteractedCount} times.", ?Duration := 2.0, ?Color := color{R:=1.0})
            if (not IsVisible?):
                set MeshComp.Visible = true
                set IsVisible = true
            else:
                set MeshComp.Visible = false
                set IsVisible = false
  1. Create an empty entity with mesh, interactable component and script. First interaction spawns step 1’s Prefab (still able to toggle child visibility). Second interaction moves the PrefabEntity to another entity, but the bug will disabling its toggle capability.
create_component<public> := class<final_super>(component):

    @editable
    TopPoint: entity = entity{}

    var IsCreated: logic = false
    var MeshEnableEntity: entity = entity{}

    OnSimulate<override>()<suspends>: void =
        if (InteracteComp := Entity.GetComponent[interactable_component]):
            InteracteComp.SucceededEvent.Subscribe(OnInteracted)

    OnInteracted(Agent: agent): void =
        if (not IsCreated?):
            if (SimEntity := Entity.GetSimulationEntity[]):
                set MeshEnableEntity = P_MeshEnable{}
                SimEntity.AddEntities(array{MeshEnableEntity})
                set IsCreated = true
        else:
            TopPoint.AddEntities(array{MeshEnableEntity})
            MeshEnableEntity.SetLocalTransform(transform{})

Expected Result

Like pre-V39.30, entities function normally after parent change.

Observed Result

Entities function broken, and I can`t toggle child visibility.

Platform(s)

windows11

Video

FORT-1045386 has been ‘Closed’ as a duplicate of an existing known issue.