Tweaking movement and parameters for controller

This commit is contained in:
Kevin Poretti 2022-03-15 16:04:27 -04:00
parent e235de93f2
commit 493cca3fee
5 changed files with 23 additions and 7 deletions

Binary file not shown.

BIN
SwordNGun/Content/Maps/MovementTest.umap (Stored with Git LFS)

Binary file not shown.

View File

@ -10,7 +10,6 @@
#include "GameFramework/SpringArmComponent.h"
#include "Kismet/KismetMathLibrary.h"
static int32 CharacterMovementDebug = 0;
FAutoConsoleVariableRef CVARCharacterMovementDebug(TEXT("SNG.CharacterMovementDebug.Show"),
CharacterMovementDebug,
@ -114,6 +113,16 @@ void ASNGCharacterBase::MoveRight(float Value)
AddMovementInput(UKismetMathLibrary::GetRightVector(ViewRotation), Value);
}
void ASNGCharacterBase::TurnRate(float Value)
{
AddControllerYawInput(Value * 50.0f * GetWorld()->DeltaTimeSeconds);
}
void ASNGCharacterBase::LookUpRate(float Value)
{
AddControllerPitchInput(Value * 50.0f * GetWorld()->DeltaTimeSeconds);
}
void ASNGCharacterBase::StartJump()
{
if(!CanJump())
@ -175,9 +184,7 @@ FVector ASNGCharacterBase::GetInputAsWorldDirection()
}
FRotator ViewRotation = FRotator(0.0f, MyController->GetControlRotation().Yaw, 0.0f);
FVector ForwardInput = UKismetMathLibrary::GetForwardVector(ViewRotation) * InputDirection.Y;
FVector RightInput = UKismetMathLibrary::GetRightVector(ViewRotation) * InputDirection.X;
return ForwardInput + RightInput;
@ -245,6 +252,11 @@ void ASNGCharacterBase::SetupPlayerInputComponent(UInputComponent* PlayerInputCo
PlayerInputComponent->BindAxis("Turn", this, &ASNGCharacterBase::AddControllerYawInput);
PlayerInputComponent->BindAxis("LookUp", this, &ASNGCharacterBase::AddControllerPitchInput);
// controller camera movement
PlayerInputComponent->BindAxis("TurnRate", this, &ASNGCharacterBase::TurnRate);
PlayerInputComponent->BindAxis("LookUpRate", this, &ASNGCharacterBase::LookUpRate);
// actions
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ASNGCharacterBase::StartJump);
PlayerInputComponent->BindAction("Jump", IE_Released, this, &ASNGCharacterBase::StopJumping);
}

View File

@ -59,6 +59,10 @@ protected:
void MoveRight(float Value);
void TurnRate(float Value);
void LookUpRate(float Value);
void StartJump();
virtual void Landed(const FHitResult& Hit) override;