我遇到了一个非常奇怪的问题,希望有人可以帮助我。
我有一个演员(ChNPC.h),我想为其附加一个组件(InteractComponent.h)。这个组件创建了另一个组件(m_innerSphere),但是当我想从此类创建蓝图并修改(m_innerSphere)的转换时,我的问题就来了。编译后,它将始终重置为初始变换位置。
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");
}
}
}