Including EngineMinimal.h or the specific Engine components needed by the class does always fix it, but you’re right: this is something I want to avoid.
I cannot replicate this in a new project, which is why I do think it’s something to do with configuration/linking.
Below is an example of a use case that compiles in an empty project but not my own. (Throws “use of undefined type “USkeletalMeshComponent”” and ‘=’ cannot convert from ‘USkeletalMeshComponent*’ to ‘USceneComponent *’)
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "CustomActor.generated.h"
UCLASS()
class TEST_API ACustomActor : public AActor
{
GENERATED_BODY()
public:
ACustomActor();
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
USkeletalMeshComponent* MeshComp;
};
//CPP
ACustomActor::ACustomActor()
{
MeshComp = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("MeshComp"));
if (MeshComp) {
RootComponent = MeshComp;
}
}
// Derived Class:
#pragma once
#include "CoreMinimal.h"
#include "CustomActor.h"
#include "CustomActor_DerivedClass.generated.h"
UCLASS()
class TEST_API ACustomActor_DerivedClass : public ACustomActor
{
GENERATED_BODY()
protected:
void TestFunction();
};
// CPP
#include "CustomActor_DerivedClass.h"
void ACustomActor_DerivedClass::TestFunction() {
FVector Location = MeshComp->GetSocketLocation(NAME_None);
}