Reproduce in 19.2
In 19.2, you can reproduce the first issue by meeting these conditions (1) calling CreateChildActor() in the constructor. In such a case, the following happens:
- CreateChildActor(), of course, calls "CreateChildActor()" (in ChildActorComponent.cpp)
- At line 561 of ChildActorComponent.cpp, if the child actor's class has been successfully spawned, the code will call the following:(
- In Actor.cpp at line 1508, this in turn calls: RootComponent->AttachToComponent(Parent, AttachmentRules, SocketName).
- Now since the RootComponent is a sceneComponent and this method is not virtual, then "USceneComponent::AttachToComponent" will be called.
ChildActor->AttachToComponent(this, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
The problem:
Now since the above ChildActorComponent code unconditionally called AttachToComponent with the attachment rule: “SnapToTargetNotIncludingScale”, the second ensureMsgf in the screenshot will fail since it is “ensuring” that the attachment rules are keepRelative. . (SceneComponent.cpp at line 1678). Specifically, this fails:
ensureMsgf(AttachmentRules.LocationRule == EAttachmentRule::KeepRelative && AttachmentRules.RotationRule == EAttachmentRule::KeepRelative && AttachmentRules.ScaleRule == EAttachmentRule::KeepRelative, TEXT("AttachToComponent when called from a constructor is only setting up attachment and will always be treated as KeepRelative. Consider calling SetupAttachment directly instead."));
Let me know if I missed anything or need further caveats to reproduce.