Description

UE allows actors to be attached to other actors. More precisely, it allows the root component of an actor (child) to be attached to any component of another actor (parent). From now on, "parent" and "child" refer to this kind of attachment, and not to the use of ChildActorComponent.

When function "AttachActorToComponent" is used with the root component of the parent actor, everything works correctly. When running a game, calling that function with a non-root parent component also works as expected. However, inside the Editor, the resulting hierarchy after an attachment to a non-root parent component is not properly handled across some operations. After such an attachment:

A) Moving/Rotating the parent actor, or the parent actor's root component, makes the child actor snap to its parent component (incorrectly loses its relative transform)
B) Canceling the movement/rotation of the parent actor with the ESC key breaks the attachment completely
C) Recompiling the blueprint of the parent actor reattaches the child actor to the root component of the parent (incorrectly loses its previous parent component)

The behaviors above were tested in UE 5.2.1 and UE 5.4.2. The reason for (A) seems to be related to the implementation of AActor::RerunConstructionScripts(). After passing the check "if (bUseRootComponentProperties)", a structure "FAttachedActorInfo" is built with a zero "Relative Transform", and later the attachment is done with rule "FAttachmentTransformRules::SnapToTargetIncludingScale". This might be a consequence of having no "ActorTransactionAnnotation" available, but the preliminary investigation did not go that far.

Interestingly, in UE 4.27.2, operations (A) and (C) above result in the incorrect reattachment of the child actor to the root component of the parent (but no snapping as in (A) above). In UE 4.23.1, moving the parent actor's root component results in correct behavior, but moving the parent actor itself (not selecting its root component in the details panel) also gives the same results as in 4.27. The preliminary investigation did not check earlier versions of the engine.

 

Steps to Reproduce
  • Open the editor, create a blank map of any type (Basic or Open World)
  • Create a blueprint actor "BP_Child" and add a shape component to it. Compile and save
  • Create a blueprint actor "BP_Parent"
  • Add a SceneComponent named "AttachPoint". Move/Rotate it visually away from the root
  • Add two shape components, one below the root and one below AttachPoint
  • Add a variable "ActorToAttach" of type "Actor", make it instance-editable
  • Add a Custom Event "Attach Now", enable "Call in Editor"
  • Implement the custom event by calling "Attach Actor to Component":
  • Target <-- ActorToAttach
  • Parent <-- Self.AttachPoint
  • Location Rule <-- Keep World
  • Rotation Rule <-- Keep World
  • Scale Rule <-- Keep World
  • Compile and save.
  • Add an instance of BP_Child to the world
  • Add an instance of BP_Parent to the world
  • Move/Rotate it visually away from BP_Child
  • In the Details Panel, set "ActorToAttach" to BP_Child

Test (A)

  • In the Details Panel for BP_Parent, click on "Attach Now"
  • Check that the actors were attached in the Outliner
  • Attempt to move/rotate BP_Parent
  • BP_Child will snap to the position/rotation of BP_Parent.AttachPoint

Test (B)

  • Detach the actors manually
  • In the Details Panel for BP_Parent, click on "Attach Now"
  • Check that the actors were attached in the Outliner
  • Attempt to move/rotate BP_Parent, but press ESC during the operation
  • BP_Child will be detached from BP_Parent

Test (C)

  • Detach the actors manually
  • In the Details Panel for BP_Parent, click on "Attach Now"
  • Check that the actors were attached in the Outliner
  • Attempt to move/rotate BP_Parent.AttachPoint
  • BP_Child moves as expected
  • Edit BP_Parent and click on "Compile"
  • Attempt to move/rotate BP_Parent.AttachPoint
  • BP_Child does not move anymore (but does move along with BP_Parent.Root)

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-219163 in the post.

0
Login to Vote

Backlogged
CreatedJul 3, 2024
UpdatedJul 16, 2024
View Jira Issue