Hi there,
i’ve been following Rama’s tutorial https://wiki.unrealengine.com/Custom_Character_Movement_Component and in my character source i got this errormessage:
Error: identifier “UTFP_CharacterMovementComponent” is undefined.
Could somebody explain to me what that means and/or what i am missing?
TFP_Character.h
#pragma once
#include "GameFramework/Character.h"
#include "TFP_Character.generated.h"
/**
*
*/
UCLASS()
class TEST_FIRSTPERSON_API ATFP_Character : public ACharacter
{
GENERATED_UCLASS_BODY()
virtual void BeginPlay() OVERRIDE;
protected:
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) OVERRIDE;
//handles moving forward/backward
UFUNCTION()
void MoveForward(float Val);
//handles strafing
UFUNCTION()
void MoveRight(float Val);
};
TFP_Character.cpp
#include "TEST_FirstPerson.h"
#include "TFP_Character.h"
ATFP_Character::ATFP_Character(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP.SetDefaultSubobjectClass<UTFP_CharacterMovementComponent>(ACharacter::CharacterMovementComponentName))
{
}
void ATFP_Character::BeginPlay(){
Super::BeginPlay();
if (GEngine)
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("TFP_Character !"));
JumpKeyHoldTime = 0.0f;
JumpMaxHoldTime = 5.0f;
}
void ATFP_Character::SetupPlayerInputComponent(UInputComponent* InputComponent){
// set up gameplay key bindings
InputComponent->BindAxis("MoveForward", this, &ATFP_Character::MoveForward);
InputComponent->BindAxis("MoveRight", this, &ATFP_Character::MoveRight);
InputComponent->BindAxis("Turn", this, &ATFP_Character::AddControllerYawInput);
InputComponent->BindAxis("LookUp", this, &ATFP_Character::AddControllerPitchInput);
InputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
InputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);
}
void ATFP_Character::MoveForward(float Value){
if ((Controller != NULL) && (Value != 0.0f)){
// find out which way is forward
FRotator Rotation = Controller->GetControlRotation();
// Limit pitch when walking or falling
if (CharacterMovement->IsMovingOnGround() || CharacterMovement->IsFalling())
Rotation.Pitch = 0.0f;
// add movement in that direction
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);
AddMovementInput(Direction, Value);
}
}
void ATFP_Character::MoveRight(float Value){
if ((Controller != NULL) && (Value != 0.0f)){
// find out which way is right
const FRotator Rotation = Controller->GetControlRotation();
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);
// add movement in that direction
AddMovementInput(Direction, Value);
}
}
TFP_CharacterMovementComponent.h
#pragma once
#include "GameFramework/CharacterMovementComponent.h"
#include "TFP_CharacterMovementComponent.generated.h"
/**
*
*/
UCLASS()
class TEST_FIRSTPERSON_API UTFP_CharacterMovementComponent : public UCharacterMovementComponent
{
GENERATED_UCLASS_BODY()
protected:
//Init
virtual void InitializeComponent() OVERRIDE;
//Tick
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) OVERRIDE;
};
TFP_CharacterMovementComponent.cpp
#include "TEST_FirstPerson.h"
#include "TFP_CharacterMovementComponent.h"
#include "TFP_GameMode.h"
UTFP_CharacterMovementComponent::UTFP_CharacterMovementComponent(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
}
void UTFP_CharacterMovementComponent::InitializeComponent()
{
Super::InitializeComponent();
//~~~~~~~~~~~~~~~~~
//UE_LOG //comp Init!
}
//Tick Comp
void UTFP_CharacterMovementComponent::TickComponent(float DeltaTime, enum ELevelTick TickType,
FActorComponentTickFunction *ThisTickFunction){
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//UE_LOG //custom comp is ticking!!!
}