Issues getting player input properly setup

I am trying to translate this Blueprint tutorial into C++ code.

I started with the main 3rd person C++ project. I have two issues at this point.

GetActorForwardVector() for moving backwards always points in the direction that I spawned. So doesn’t matter which direction you turn to, if you start walking backwards you always go in the original backwards location.


void ATestCharacter::MoveForward(float Value)
{
	if ((Controller != NULL) && (Value != 0.0f))
	{ 
		// find out which way is forward
		const FRotator Rotation = Controller->GetControlRotation();
		const FRotator YawRotation(0, Rotation.Yaw, 0);
		// get forward vector
		FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);		
		if (Value < 0)
		{
			Direction = GetActorForwardVector();
			Value *= 0.5f; 
		}
		AddMovementInput(Direction, Value); 
	}
}

The other problem is my mouse look adds all kinds of weird pitch. The default one kinda locks you into the x,y planes, but with this I am getting all kinds of Z.


void ATestCharacter::TurnAtRate(float Rate)
{
	// calculate delta for this frame from the rate information
	//AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds());
	if (!bRightMouseDown)
		return;

	CameraBoom->AddRelativeRotation(FRotator(0.0f, Rate, 0.0f));
//	CameraBoom->AddLocalRotation(FRotator(0.0f, Rate, 0.0f));
	//AddControllerYawInput(Rate);
}

void ATestCharacter::LookUpAtRate(float Rate)
{
	if (!bRightMouseDown)
		return;
	CameraBoom->AddRelativeRotation(FRotator(Rate, 0.0f, 0.0f));
	//CameraBoom->AddLocalRotation(FRotator(Rate, 0.0f, 0.0f));
	//AddControllerPitchInput(Rate);
	// calculate delta for this frame from the rate information
	//AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());
}

Here’s full source code:

Header: // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.#pragma once#inc - Pastebin.com
Source: // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. #include "Engin - Pastebin.com
Inputs: http://i.imgur.com/GjZXPUG.png

Can anyone quickly see where I’m ******** up? It’s kind of hard to translate Blueprints correctly when the functions aren’t really 1:1.