Error C2027 & C2227 for a USplineComponent issue

I’m having an issue where I created an actor class and wanted to create a default subobject of USplineComponent but it will give me two error’s, one for creating the default subobject in the constructor and immediately after that the other for setting its attachment. I don’t know if I need to include a header file or something but I have no clue how to fix this.

First one:
"error C2027: use of undefined type ‘USplineComponent’

Second one:
“error C2227: left of ‘->SetupAttachment’ must point to class/struct/union/generic type”

What my code looks like without all the variable declarations, methods/functions, and such that areant important:

header:

    #pragma once
    
    #include "GameFramework/Actor.h"
    #include "MotionControllerComponent.h"
    #include "SteamVRChaperoneComponent.h"
    #include "SteamVRFunctionLibrary.h"
    #include "InteractablesInterface.h"
    #include "VRMotionController.generated.h"
    
    class USplineMeshComponent;
    
    UCLASS()
    class VIVETESTINGPROJECT_API AVRMotionController : public AActor, public IInteractablesInterface
    {
    	GENERATED_BODY()
    	
    protected:
    	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Hand Defaults")
    		class USplineComponent* ArcSpline;
    
    public:
    // Sets default values for this actor's properties
    	AVRMotionController();
    
    	// Called when the game starts or when spawned
    	virtual void BeginPlay() override;
    	
    	// Called every frame
    	virtual void Tick( float DeltaSeconds ) override;

FORCEINLINE class USplineComponent* GetArcSpline() const { return ArcSpline; }

}

cpp. (in the constructor):

#include "ViveTestingProject.h"
#include "HeadMountedDisplay.h"
#include "VRMotionController.h"

#pragma region Defaults

// Sets default values
AVRMotionController::AVRMotionController()
{

	ArcSpline = CreateDefaultSubobject<USplineComponent>(TEXT("ArcSpline"));
	ArcSpline->SetupAttachment(handMesh);

}

Ok great thank you! I saw others that had the issue and they included a header but I didn’t know if Spline Components have to be included too or something and they are! Thank you again!

Hey -

If you run into a “use of undefined type” issue, the best thing to do is go to the documentation page (Unreal Engine 5.1 Documentation | Unreal Engine 5.1 Documentation) and search for what is causing the error. In the case of USplineComponent, adding an include statement for the file “Runtime/Engine/Classes/Components/SplineComponent.h” should allow the compiler to recognize the datatype and allow the code to compile.

Cheers