Being a noob at C++ I used “A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums” by Rama to get skeletal components to operate on my C++ pawn so I could add a skeletal mesh.
The problem is that being a noob I have no idea about how to fix the following errors.
On the C++ source file line 42, 45, 93 and 96, UGHFF and Super: name followed by ‘::’ must be a class or name space name. Line 48 “OwningPawn” and “TryGetPawnOwner” is undefined. Line 99: “OwningPawn” is undefined. Line 105: IsMoving is undefined. This is the screen shot to the header file.
// Fill out your copyright notice in the Description page of Project Settings.
#include “The_Last_Bat.h”
#include “GHFF.h”
// Sets default values.
AGHFF::AGHFF()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;
// Creates our root component that is our scene component.
RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("SceneComponent"));
// Create our springarm component.
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArmComponent"));
// Attach the spring arm component to our root component.
SpringArm->AttachTo(RootComponent);
// Set up our spring arm direction maths.
SpringArm->SetRelativeLocationAndRotation(FVector(0.f, 0.f, 0.f), FRotator(0.f, 0.f, 0.f));
// Creates first poson effect.
SpringArm->TargetArmLength = 0.f;
// Lag the camera for a certan head movement speed.
SpringArm->bEnableCameraLag = true;
// This leaves the max speed the player can turn the bats head.
SpringArm->CameraLagSpeed = 1000.f;
// We want the camera to be compleatly independant with the head. So the player can see most directions with out turning.
SpringArm->bUsePawnControlRotation = false;
// Creates our camera component.
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
// Attachers the camera component to the spring arm component.
Camera->AttachTo(SpringArm, USpringArmComponent::SocketName);
// Set up values.
CurrentPitchSpeed = 0.f;
CurrentYawSpeed = 0.f;
CurrentRollSpeed = 0.f;
CurrentForwardSpeed = 50.f;
}
//This function is like PostInitAnimtree in UE3
void UGHFF::NativeInitializeAnimation()
{
//Very Important Line
Super::NativeInitializeAnimation();
//Cache the owning pawn for use in Tick
OwningPawn = TryGetPawnOwner();
}
// Called when the game starts or when spawned.
void AGHFF::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame.
void AGHFF::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// Calculate change in rotation this frame.
FRotator DeltaRotation(0, 0, 0);
// Calculate change in rotation this frame.
DeltaRotation.Pitch = CurrentPitchSpeed * DeltaTime;
// Calculate change in rotation this frame.
DeltaRotation.Yaw = CurrentYawSpeed * DeltaTime;
//Calculate change in rotation this frame.
DeltaRotation.Roll = CurrentRollSpeed * DeltaTime;
// Rotate GHFF.
AddActorLocalRotation(DeltaRotation);
// Rolls our player with the camera.
FRotator NewRotation = GetActorRotation();
NewRotation.Roll += CameraInput.Z;
SetActorRotation(NewRotation);
// Handle movement inputs.
{
if (!PlayerInput.IsZero())
{
PlayerInput = PlayerInput.GetSafeNormal() * 100.f;
FVector NewLocation = GetActorLocation();
NewLocation += GetActorForwardVector() * PlayerInput.X * DeltaTime;
NewLocation += GetActorRightVector() * PlayerInput.Y * DeltaTime;
NewLocation += GetActorUpVector() * PlayerInput.Z * DeltaTime;
SetActorLocation(NewLocation);
}
}
}
//Tick
void UGHFF::NativeUpdateAnimation(float DeltaTimeX)
{
//Very Important Line
Super::NativeUpdateAnimation(DeltaTimeX);
//Always Check Pointers
if (!OwningPawn)
{
return;
}
//Set whether moving or not
IsMoving = (OwningPawn->GetVelocity().SizeSquared() > 25);
}
// Called to bind functionality to input.
void AGHFF::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
Super::SetupPlayerInputComponent(InputComponent);
// Checks there is a input component.
check(InputComponent);
// Gets mouse movement for camera pitch.
InputComponent->BindAxis("CameraPitch", this, &AGHFF::PitchCamera);
// Gets mouse movement for camera yaw.
InputComponent->BindAxis("CameraYaw", this, &AGHFF::YawCamera);
// Gets the keyboard for moveing the player left and right.
InputComponent->BindAxis("MoveRight", this, &AGHFF::MoveRight);
// Gets the keyboard for moveing the player foward and hovering.
InputComponent->BindAxis("MoveFoward", this, &AGHFF::MoveFoward);
// Gets the mouse for changeing the altitude.
InputComponent->BindAxis("MoveUp", this, &AGHFF::MoveUp);
}
// Called to bind functionality to input.
void AGHFF::PitchCamera(float AxisValue)
{
CameraInput.Y = AxisValue;
}
// Called to bind functionality to input.
void AGHFF::YawCamera(float AxisValue)
{
CameraInput.X = AxisValue;
}
// Called to bind functionality to input.
void AGHFF::RollCamera(float AxisValue)
{
CameraInput.Z = AxisValue;
}
// Called to bind functionality to input.
void AGHFF::MoveUp(float AxisValue)
{
PlayerInput.X = FMath::Clamp(AxisValue, 1.0f, -1.0f);
}
// Called to bind functionality to input.
void AGHFF::MoveRight(float AxisValue)
{
PlayerInput.Y = FMath::Clamp(AxisValue, 1.0f, -1.0f);
}
// Called to bind functionality to input.
void AGHFF::MoveFoward(float AxisValue)
{
PlayerInput.Z = FMath::Clamp(AxisValue, 1.0f, -1.0f);
}