My movement speed drops when I look down. I tried using the provided movement code template, but it didn't resolve the issue. Here's the code:
// Fill out your copyright notice in the Description page of Project Settings.
#include "CPPMainPlayer.h"
ACPPMainPlayer::ACPPMainPlayer() : Super()
{
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArmComponent"));
SpringArm->SetupAttachment(RootComponent);
SpringArm->TargetArmLength = 300.0f;
SpringArm->bUsePawnControlRotation = true;
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("MainCamerea"));
Camera->SetupAttachment(SpringArm);
Camera->bUsePawnControlRotation = false;
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
}
void ACPPMainPlayer::SetupPlayerInputComponent(UInputComponent *MyPlayerInput)
{
Super::SetupPlayerInputComponent(MyPlayerInput);
MyPlayerInput->BindAxis("MoveForwardBackward", this, &ACPPMainPlayer;::MoveForwardBackward);
MyPlayerInput->BindAxis("MoveRightLeft", this, &ACPPMainPlayer;::MoveRightLeft);
MyPlayerInput->BindAxis("Turn", this, &ACPPMainPlayer;::AddControllerYawInput);
MyPlayerInput->BindAxis("Look", this, &ACPPMainPlayer;::AddControllerPitchInput);
MyPlayerInput->BindAction("Jump", IE_Pressed, this, &ACPPMainPlayer;::Jump);
MyPlayerInput->BindAction("Jump", IE_Released, this, &ACPPMainPlayer;::StopJump);
}
void ACPPMainPlayer::MoveForwardBackward(float Value)
{
FVector Direction = FRotationMatrix(Controller->GetControlRotation()).GetScaledAxis(EAxis::X);
AddMovementInput(Direction, Value);
}
a
void ACPPMainPlayer::MoveRightLeft(float Value)
{
FVector Direction = FRotationMatrix(Controller->GetControlRotation()).GetScaledAxis(EAxis::Y);
AddMovementInput(Direction, Value);
}
void ACPPMainPlayer::Jump()
{
bPressedJump = true;
}
void ACPPMainPlayer::StopJump()
{
bPressedJump = false;
}