Not sure what I did wrong. It feels like the include isn’t actually working properlty or maybe I am missing the correct include.
Anyone have an idea what is wrong??? Both of the objects should have identifiers since they are being declared.
When I compile I keep getting an error about:
D:\Epic Games\UE_4.26\Unreal Training\ToonTanks\Source\ToonTanks\Pawns\PawnTank.cpp(55) : error C2065: ‘MoveDirection’: undeclared identifier
D:\Epic Games\UE_4.26\Unreal Training\ToonTanks\Source\ToonTanks\Pawns\PawnTank.cpp(43) : error C2065: ‘MoveDirection’: undeclared identifier
// Fill out your copyright notice in the Description page of Project Settings.
#include "PawnTank.h"
#include "GameFramework/SpringArmComponent.h"
#include "Camera/CameraComponent.h"
#include "GameFrameWork/Actor.h"
APawnTank::APawnTank()
{
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring Arm"));
SpringArm->SetupAttachment(RootComponent);
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
Camera->SetupAttachment(SpringArm);
}
// Called when the game starts or when spawned
void APawnTank::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APawnTank::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
Rotate();
Move();
}
// Called to bind functionality to input
void APawnTank::SetupPlayerInputComponent(UInputComponent *PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis("MoveFoward", this, &APawnTank::CalculateMoveInput);
PlayerInputComponent->BindAxis("Turn", this, &APawnTank::CalculateRotateInput);
}
void APawnTank::CalculateMoveInput(float Value)
{
MoveDirection = FVector(Value * MoveSpeed * GetWorld()->DeltaTimeSeconds, 0, 0);
}
void APawnTank::CalculateRotateInput(float Value)
{
float RotateAmount = Value * RotateSpeed * GetWorld()->DeltaTimeSeconds;
FRotator Rotation = FRotator(0, RotateAmount, 0);
RotationDirection = FQuat(Rotation);
}
void APawnTank::Move()
{
AddActorLocalOffset(MoveDirection, true);
}
void APawnTank::Rotate()
{
AddActorLocalRotation(RotationDirection, true);
}