Character wont rotate after 4.18 update

Third Person character wont rotate after 4.18 update up to 4.24 (I tried all). It works in 4.17.

This code works fine in 4.17. The camera can rotate but the character model don’t. It stays with arms out straight facing north.

EDIT: It works fine going forward or back, but going right always goes in the same direction. Doesn’t go right of the cameras position.

I think SpringArm->GetRightVector() isn’t working right in the newer versions.



#include "BaseCharacter.h"
#include "TPS2.h"
//#include "PlatformerPlayerState.h"
#include "Net/UnrealNetwork.h"
#include "GameFramework/SpringArmComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "Camera/CameraComponent.h"
#include "Components/ArrowComponent.h"
#include "Components/InputComponent.h"
#include "Components/CapsuleComponent.h"
#include "GameFramework/Controller.h"


// Sets default values
ABaseCharacter::ABaseCharacter()
{
    PrimaryActorTick.bCanEverTick = true;

    //Set up our springarm to hold our camera
    SpringArm = CreateDefaultSubobject<USpringArmComponent>(FName("Camera Boom"));
    //Do not allow spring arm to rotate with character
    SpringArm->bUsePawnControlRotation = false;
    //Do not allow it to be affected by relative rotation of character
    SpringArm->bAbsoluteRotation = true;
    //Length of arm
    SpringArm->TargetArmLength = 700.f;
    //Attach to root
    SpringArm->SetupAttachment(RootComponent);

    //Set up the camera
    Camera = CreateDefaultSubobject<UCameraComponent>(FName("Camera"));
    //Give it a wider FOV
    Camera->FieldOfView = 110.f;
    //attach to SpringArm
    Camera->SetupAttachment(SpringArm);

    //Set up our forward direction
    TraceDirection = CreateDefaultSubobject<UArrowComponent>(FName("Trace Direction"));
    //attach to root
    TraceDirection->SetupAttachment(RootComponent);

    //set up basic network replication
    bReplicates = true;
    bAlwaysRelevant = true;
    bReplicateMovement = true;

    //Set up character movement properties

    //rotate the character in the direction its moving
    GetCharacterMovement()->bOrientRotationToMovement = true;
    //don't rotate based on controller input
    bUseControllerRotationPitch = false;
    bUseControllerRotationRoll = false;
    bUseControllerRotationYaw = false;

    //jump higher
    GetCharacterMovement()->JumpZVelocity = 1000.f;
    //fall faster
    GetCharacterMovement()->GravityScale = 2.f;
    //Allow some control of character while airborne
    GetCharacterMovement()->AirControl = 0.8f;

}

void ABaseCharacter::MoveForward(float amount)
{
    //add movement input in the direction the camera is facing
    if (Controller && amount) {
        AddMovementInput(SpringArm->GetForwardVector(), amount);
    }
}

void ABaseCharacter::MoveRight(float amount)
{
    //add input in the camera's right direction
    if (Controller && amount) {
        AddMovementInput(SpringArm->GetRightVector(), amount);
    }
}

void ABaseCharacter::RotateCamera(float amount)
{
    //add rotation on the spring arm's z axis
    if (Controller && amount) {
        FVector rot = SpringArm->GetComponentRotation().Euler();
        rot += FVector(0, 0, amount);
        SpringArm->SetWorldRotation(FQuat::MakeFromEuler(rot));
    }
}

void ABaseCharacter::ChangeCameraHeight(float amount)
{
    //add rotation on spring arm's y axis. Clamp between -45 and -5
    if (Controller && amount) {
        FVector rot = SpringArm->GetComponentRotation().Euler();

        float originalHeight = rot.Y;
        originalHeight += amount;
        originalHeight = FMath::Clamp(originalHeight, -45.f, -5.f);

        rot = FVector(0, originalHeight, rot.Z);
        SpringArm->SetWorldRotation(FQuat::MakeFromEuler(rot));
    }
}

// Called when the game starts or when spawned
void ABaseCharacter::BeginPlay()
{
    Super::BeginPlay();
    //set the spring arm behind our character
    SpringArm->SetRelativeRotation(FQuat::MakeFromEuler(FVector(0, -25, 180)));
}

// Called every frame
void ABaseCharacter::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);

}

// Called to bind functionality to input
void ABaseCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
    Super::SetupPlayerInputComponent(PlayerInputComponent);

    //Bind inputs
    InputComponent->BindAction("Jump", EInputEvent::IE_Pressed, this, &ACharacter::Jump);

    InputComponent->BindAxis("ChangeCameraHeight", this, &ABaseCharacter::ChangeCameraHeight);
    InputComponent->BindAxis("RotateCamera", this, &ABaseCharacter::RotateCamera);
    InputComponent->BindAxis("MoveForward", this, &ABaseCharacter::MoveForward);
    InputComponent->BindAxis("MoveRight", this, &ABaseCharacter::MoveRight);
}



I dont believe it. I actually fixed it by using some code from the Third Person template class.


    if ((Controller != NULL) && (amount != 0.0f))
    {
        // find out which way is right
        const FRotator Rotation = Controller->GetControlRotation();
        const FRotator YawRotation(0, Rotation.Yaw, 0);

        // get right vector
        const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
        // add movement in that direction
        AddMovementInput(Direction, amount);
    }