I’m trying to setup a character so that it will rotate to the direction of the movement. e.g. push up it faces up, push left it faces left. I have set bUseControllerRotationYaw = false
and GetCharacterMovement()->bOrientRotationToMovement = true;
. From what I have been able to gather this is really all I need to do to get the movement to work as desired.
Here is the code I’m using for the character:
// Fill out your copyright notice in the Description page of Project Settings.
#include "RPG.h"
#include "RPGCharacter.h"
// Sets default values
ARPGCharacter::ARPGCharacter()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
bUseControllerRotationYaw = false;
GetCharacterMovement()->bOrientRotationToMovement = true;
GetCharacterMovement()->RotationRate = FRotator(0.0f, 0.0f, 540.0f);
GetCharacterMovement()->MaxWalkSpeed = 400.0f;
}
void ARPGCharacter::MoveVertical(float Value)
{
if(Controller != NULL && Value != 0.0f)
{
const FVector moveDir = FVector(1,0,0);
AddMovementInput(moveDir, Value);
}
}
void ARPGCharacter::MoveHorizontal(float Value)
{
if(Controller != NULL && Value != 0.0f)
{
const FVector moveDir = FVector(0,1,0);
AddMovementInput(moveDir, Value);
}
}
// Called when the game starts or when spawned
void ARPGCharacter::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ARPGCharacter::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
// Called to bind functionality to input
void ARPGCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
Super::SetupPlayerInputComponent(InputComponent);
}
I have created a blueprint for the character and Inherited from ARPGCharacter
. I have added the mannequin that is bundled with the animation starter kit as mesh and a customer camera class.
I’m not sure where else I should be looking to configure this correctly