UE 5.1. Considering I have the following component UTileInteractionComponent : public USceneComponent
and inside it I have another component:
class GAME_API UTileInteractionComponent : public USceneComponent
{
GENERATED_BODY()
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
UArrowComponent* ArrowComponent;
// ...
}
// -----------------------------
// Constructor...
// -----------------------------
UTileInteractionComponent::UTileInteractionComponent()
{
PrimaryComponentTick.bCanEverTick = false;
ArrowComponent = CreateDefaultSubobject<UArrowComponent>(TEXT("TraceTilesDirectionArrow"));
ArrowComponent->AttachToComponent(this, FAttachmentTransformRules::KeepRelativeTransform);
ArrowComponent->SetRelativeRotation(FRotator(-90.f, 0.f, 0.f));
}
A UTileInteractionComponent
is instantiated into a Character
:
ABuilderCharacter::ABuilderCharacter()
{
TileInteractionComponent = CreateDefaultSubobject<UTileInteractionComponent>(TEXT("Tile Interaction Component")); TileInteractionComponent->SetupAttachment(RootComponent);
}
It works in DevelopmentEditor
, but it crashes in Shipping
:
Error LogOutputDevice Ensure condition failed: false [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Components\SceneComponent.cpp] [Line: 2004]
Error LogOutputDevice Template Mismatch during attachment. Attaching instanced component to template component. Parent 'Tile Interaction Component' (Owner 'Default__BP_ThirdPersonCharacter_C') Self 'TraceTilesDirectionArrow' (Owner 'BP_ThirdPersonCharacter_C_0').
The culprit is ArrowComponent->AttachToComponent(this, FAttachmentTransformRules::KeepRelativeTransform);
inside UTileInteractionComponent
.
How to have this component hierarchy Character → Component → InnerComponent, while being able to attach the inner component with FAttachmentTransformRules::KeepRelativeTransform
?
Maybe related - seems that it’s still a bug with UE 5.1?
- Attaching one component to another crash: 'template mismatch during attachment' - #23 by thomasm
- Adding UBoxComponent to a custom PlayerStart class crashes gameplay
Other questions kind of related: