Here is my code for PositionReport.cpp, the BeginPlay() part.
void UPositionReport::BeginPlay()
{
Super::BeginPlay();
FString ObjectName = GetOwner()->GetName();
FString ObjectPos = GetOwner()->GetTransform().GetLocation().ToString();
UE_LOG(LogTemp, Warning, TEXT("%s is at %s"), *ObjectName, *ObjectPos);
}
GetOwner() is marked as an error, and while building, it also says that one build has failed. However, in Unreal, the code works. The error reads as: Pointer to Incomplete Class Type Is Not Allowed. I found GetOwner definition:
FORCEINLINE_DEBUGGABLE AActor* UActorComponent::GetOwner() const
{
#if WITH_EDITOR
// During undo/redo the cached owner is unreliable so just used GetTypedOuter
if (bCanUseCachedOwner)
{
checkSlow(OwnerPrivate == GetActorOwnerNoninline()); // verify cached value is correct
return OwnerPrivate;
}
else
{
return GetActorOwnerNoninline();
}
#else
checkSlow(OwnerPrivate == GetActorOwnerNoninline()); // verify cached value is correct
return OwnerPrivate;
#endif
}
Can someone please tell me what is wrong? It’s really bugging me. Thanks!
P.S. Sorry if it looks weird, this is my first post, and I do not know how to put all the code together.