Tweaking movement and parameters for controller
This commit is contained in:
parent
e235de93f2
commit
493cca3fee
BIN
SwordNGun/Content/Characters/Protagonist/Animations/Locomotion/Common/BS_Common_WalkRun_Loop.uasset
(Stored with Git LFS)
BIN
SwordNGun/Content/Characters/Protagonist/Animations/Locomotion/Common/BS_Common_WalkRun_Loop.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset
(Stored with Git LFS)
BIN
SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
SwordNGun/Content/Maps/MovementTest.umap
(Stored with Git LFS)
BIN
SwordNGun/Content/Maps/MovementTest.umap
(Stored with Git LFS)
Binary file not shown.
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user