I have some troubles with the FPS tutorial.
Everything worked well until I reached the 4th part and I’ve added the MoveForward and MoveRight functions.
Now, I have 103 NULL is undefined errors and many errors like IntelliSense: cannot open source file “windows.h”, “string.h” and many other headers.
The problem comes from the line:
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxes(EAxis::X);
and in particular from GetScaledAxes() function.
If I don’t call it also the NULL I use in the if checks is recognized.
// Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.
#include "FPSProject.h"
#include "FPSCharacter.h"
AFPSCharacter::AFPSCharacter(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
}
void AFPSCharacter::BeginPlay()
{
Super::BeginPlay();
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("We are using FPSCharacter!"));
}
}
void AFPSCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
// An InputComponent is a component that defines how to handle input data and can be attached to an actor that wants to receive input
// set up gameplay key bindings
BIND_AXIS(InputComponent, "MoveForward", &AFPSCharacter::MoveForward);
BIND_AXIS(InputComponent, "MoveRight", &AFPSCharacter::MoveRight);
}
void AFPSCharacter::MoveForward(float Value)
{
if( Controller != NULL && Value != 0.0f )
{
// Get the rotation of our controller
FRotator Rotation = Controller->GetControlRotation();
// Ignore the pitch
if( CharacterMovement->IsMovingOnGround() || CharacterMovement->IsFalling() )
{
Rotation.Pitch = 0.0f;
}
// Move in the direction found
const FVector Direction = FRotationMatrix(Rotation).GetScaledAxes(EAxis::X);
AddMovementInput(Direction, Value);
}
}
void AFPSCharacter::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);
}
}
Is it a problem in the settings of the project or is it an actual coding error I’ve made?