.h
UFUNCTION()
void StartLineTrace();
UPROPERTY()
AActor* RootActor;
};
.cpp
// Called when the game starts
void ULineTraceComponent::BeginPlay()
{
Super::BeginPlay();
// 绑定射线检测事件
if (RootActor==nullptr)
{
RootActor = GetAttachmentRootActor();
}
if (RootActor!=nullptr)
{
if (RootActor->