Hello. Im trying to create something like interaction system for that I created an Interaction component which handles all the logic. Inside that component I want to add UBoxComponent as a member and attach this component to Interaction, so that when I added Interaction component to some object in editor it has collision component added with it. Here is how it looks in code:
InteractionComponent.h
UPROPERTY(VisibleAnywhere, Transient, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
class UBoxComponent* m_triggerZone = nullptr;
InteractionComponent.cpp
UInteractionComponent::UInteractionComponent()
{
PrimaryComponentTick.bCanEverTick = true;
m_triggerZone = CreateDefaultSubobject<UBoxComponent>(TEXT("Interaction trigger"));
m_triggerZone->SetBoxExtent(FVector(32.0f, 32.0f, 32.0f));
m_triggerZone->SetupAttachment(this);
}
Then I created a BP with the object I want to have, let’s say Coin and add Interaction component to it inside BP.
And everything works as it should, except one problem. If I have a coin added to the level and trying to run editor from the VS then I get this warning:
SceneComponent.cpp
ensureMsgf(false, TEXT("Template Mismatch during attachment. Attaching instanced component to template component. Parent '%s' (Owner '%s') Self '%s' (Owner '%s')."), *Parent->GetName(), *GetNameSafe(Parent->GetOwner()), *GetName(), *GetNameSafe(GetOwner()));
Is there any way to prevent this? Maybe there is an other way to achieve what I want?
Thank you!