I have a custom class called “Steering Controller” I want to add to my AIRacerPawn class which is a C++ script inherited from the AWheeledVehicle.
I am familiar with C++, but not Unreal, however when I add the SteeringController.h file I created and then add a private SteeringController reference I get the following:
error C2079: ‘AAIRacerPawn::_steeringController’ uses undefined class ‘SteeringController’
here is the steering controller header:
#pragma once
#include "CoreMinimal.h"
#include "AIRacerPawn.h"
class SteeringController
{
public:
SteeringController();
~SteeringController();
int CalculateSteerDirection(
FVector waypointPos,
FVector position,
FVector fwd,
FVector up);
};
and here is the AIRacerPawn header
#pragma once
#include "CoreMinimal.h"
#include "WheeledVehicle.h"
#include "SteeringController.h"
#include "AIRacerPawn.generated.h"
class UCameraComponent;
class USpringArmComponent;
class UTextRenderComponent;
class UInputComponent;
UCLASS(config=Game)
class AAIRacerPawn : public AWheeledVehicle
{
GENERATED_BODY()
/** Spring arm that will offset the camera */
UPROPERTY(Category = Camera, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
USpringArmComponent* SpringArm;
/** Camera component that will be our viewpoint */
UPROPERTY(Category = Camera, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
UCameraComponent* Camera;
/** SCene component for the In-Car view origin */
UPROPERTY(Category = Camera, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
class USceneComponent* InternalCameraBase;
/** Camera component for the In-Car view */
UPROPERTY(Category = Camera, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
UCameraComponent* InternalCamera;
/** Text component for the In-Car speed */
UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
UTextRenderComponent* InCarSpeed;
/** Text component for the In-Car gear */
UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
UTextRenderComponent* InCarGear;
public:
AAIRacerPawn();
/** The current speed as a string eg 10 km/h */
UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly)
FText SpeedDisplayString;
/** The current gear as a string (R,N, 1,2 etc) */
UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly)
FText GearDisplayString;
UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly)
/** The color of the incar gear text in forward gears */
FColor GearDisplayColor;
/** The color of the incar gear text when in reverse */
UPROPERTY(Category = Display, VisibleDefaultsOnly, BlueprintReadOnly)
FColor GearDisplayReverseColor;
/** Are we using incar camera */
UPROPERTY(Category = Camera, VisibleDefaultsOnly, BlueprintReadOnly)
bool bInCarCameraActive;
/** Are we in reverse gear */
UPROPERTY(Category = Camera, VisibleDefaultsOnly, BlueprintReadOnly)
bool bInReverseGear;
/** Initial offset of incar camera */
FVector InternalCameraOrigin;
// Begin Pawn interface
virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;
// End Pawn interface
// Begin Actor interface
virtual void Tick(float Delta) override;
protected:
virtual void BeginPlay() override;
public:
// End Actor interface
/** Handle pressing forwards */
void MoveForward(float Val);
/** Setup the strings used on the hud */
void SetupInCarHUD();
/** Update the physics material used by the vehicle mesh */
void UpdatePhysicsMaterial();
/** Handle pressing right */
void MoveRight(float Val);
/** Handle handbrake pressed */
void OnHandbrakePressed();
/** Handle handbrake released */
void OnHandbrakeReleased();
/** Switch between cameras */
void OnToggleCamera();
/** Handle reset VR device */
void OnResetVR();
static const FName LookUpBinding;
static const FName LookRightBinding;
private:
/**
* Activate In-Car camera. Enable camera and sets visibility of incar hud display
*
* @param bState true will enable in car view and set visibility of various if its doesnt match new state
* @param bForce true will force to always change state
*/
void EnableIncarView( const bool bState, const bool bForce = false );
/** Update the gear and speed strings */
void UpdateHUDStrings();
/* Are we on a 'slippery' surface */
bool bIsLowFriction;
SteeringController _steeringController;
public:
/** Returns SpringArm subobject **/
FORCEINLINE USpringArmComponent* GetSpringArm() const { return SpringArm; }
/** Returns Camera subobject **/
FORCEINLINE UCameraComponent* GetCamera() const { return Camera; }
/** Returns InternalCamera subobject **/
FORCEINLINE UCameraComponent* GetInternalCamera() const { return InternalCamera; }
/** Returns InCarSpeed subobject **/
FORCEINLINE UTextRenderComponent* GetInCarSpeed() const { return InCarSpeed; }
/** Returns InCarGear subobject **/
FORCEINLINE UTextRenderComponent* GetInCarGear() const { return InCarGear; }
};