Hey all, first question on here, so sorry if it’s a dumb one.
I’ve been trying to make a custom movement mode for a character that’s supposed to have a “run” state, and is kind of like classic platformers like Mario and Sonic where they ‘slip’ around.
Problem is I can’t get the custom component to initialize in the first place.
Here’s the character code:
#include “Runner.h”
#include “Camera/CameraComponent.h”
#include “GameFramework/SpringArmComponent.h”
#include “Components/InputComponent.h”
#include “GameFramework/CharacterMovementComponent.h”
#include “RunMovementComponent.h”
// Sets default values
ARunner::ARunner(const class FPostConstructInitializeProperties& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass<URunMovementComponent>(ACharacter::CharacterMovementComponentName))
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
Camera3rdView = CreateDefaultSubobject<UCameraComponent>(TEXT("3rd-Person Camera"));
MainCameraArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("3rd-Person SpringArm"));
MainCameraArm->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
MainCameraArm->bAbsoluteRotation = false; //TEMP
MainCameraArm->TargetArmLength = 750.f;
MainCameraArm->SocketOffset = FVector(0.f, 0.f, 10.f);
//Old code for attaching camera to spring arm: Camera3rdView->AttachTo(MainCameraArm, USpringArmComponent::SocketName);
Camera3rdView->AttachToComponent(MainCameraArm, FAttachmentTransformRules::KeepRelativeTransform, USpringArmComponent::SocketName);
Camera3rdView->bUsePawnControlRotation = false;
}
Now, that’s just the constructor as I doubt it has to do with the rest of my code.
Here’s my header file for the character:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Classes/Camera/CameraComponent.h"
#include "Classes/GameFramework/SpringArmComponent.h"
#include "RunMovementComponent.h"
#include "Runner.generated.h"
UCLASS()
class RUNNERBUILD_API ARunner : public ACharacter
{
GENERATED_UCLASS_BODY()
public:
ARunner();
// Sets default values for this character's properties
ARunner(const class FPostConstructInitializeProperties& ObjectInitializer);
UPROPERTY(EditAnywhere, Category = "Camera")
class UCameraComponent* Camera3rdView;
UPROPERTY(EditAnywhere, Category = "Camera")
class USpringArmComponent* MainCameraArm;
float cameraX;
float cameraY;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
void RotateCameraYaw(float value);
void RotateCameraPitch(float value);
void WalkForward(float value);
void WalkRight(float value);
void JumpStart();
void JumpStop();
};
And here’s the header for my custom movement component:
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "RunMovementComponent.generated.h"
UCLASS()
class RUNNERBUILD_API URunMovementComponent : public UCharacterMovementComponent
{
GENERATED_UCLASS_BODY()
protected:
//Init
virtual void InitializeComponent() override;
//Tick
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
};
I’m getting the errors:
E0070 “incomplete type is not allowed”
E0254 “type name is not allowed”
C2027 “use of undefined type ‘FPostConstructInitializeProperties’”
I await any suggestions you have.
Thanks in advance.