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);
}