Hi there! I have got a really strange problem hope someone can help me.
I have got an actor (ChNPC.h) and I want to attach a component (InteractComponent.h) to it. This component creates another component (m_innerSphere), but my problem comes when I want to create a blueprint from this class and modify the transform of the (m_innerSphere). After compiling it always resets to the initial transform location.
Here is the example code, thanks in advance for the help.
ChNPC.h
UPROPERTY(EditAnywhere, TextExportTransient)
UInteractComponent* m_InteractComponent;
ChNPC.cpp
AChNPC::AChNPC() {
m_InteractComponent = CreateDefaultSubobject<UInteractComponent>(TEXT("InteractComponent"), true);
}
InteractComponent.h
UPROPERTY(EditAnywhere)
USphereComponent* m_innerSphere;
InteractComponent.cpp
UInteractComponent::UInteractComponent()
{
PrimaryComponentTick.bCanEverTick = true;
if (!m_innerSphere) {
m_innerSphere = CreateDefaultSubobject<USphereComponent>(TEXT("InteractSphere"));
if (m_innerSphere) {
m_innerSphere->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
m_innerSphere->InitSphereRadius(m_interactSphereRadius);
m_innerSphere->ComponentTags.Add("Interact");
}
}
}