diff --git a/SwordNGun/Content/Characters/Protagonist/Animations/Locomotion/Common/BS_Common_WalkRun_Loop.uasset b/SwordNGun/Content/Characters/Protagonist/Animations/Locomotion/Common/BS_Common_WalkRun_Loop.uasset index e2ba283..e14d1ce 100644 --- a/SwordNGun/Content/Characters/Protagonist/Animations/Locomotion/Common/BS_Common_WalkRun_Loop.uasset +++ b/SwordNGun/Content/Characters/Protagonist/Animations/Locomotion/Common/BS_Common_WalkRun_Loop.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9270f07502802778024e6ae229d567ee269a71abdb9bc726376383bb4024556c +oid sha256:76158622300fd0652b982cfe2ef7cde04a0ee28fd8101faf7e1aecad9347d352 size 97614 diff --git a/SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset b/SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset index 7364c3d..e91bd71 100644 --- a/SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset +++ b/SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:573f605038b7a86d8ab9ee4d2b2c1d34223fa9eeda8880ba5457e6081e8fad6f -size 121112 +oid sha256:039d1630c89642de057a33b027d97d374d4d8a3fe07310c343ec76c8308c5d93 +size 121177 diff --git a/SwordNGun/Content/Maps/MovementTest.umap b/SwordNGun/Content/Maps/MovementTest.umap index 210e70a..94856af 100644 --- a/SwordNGun/Content/Maps/MovementTest.umap +++ b/SwordNGun/Content/Maps/MovementTest.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fa5b9fa26a36ecb5f6f16ecd757395570eed91cbef21ce6fa4f3657072b5dcbe +oid sha256:74fd15f88e1e5f8e8b8b5167d2749364d7fbec56235c3868759b2d819081bd22 size 949560 diff --git a/SwordNGun/Source/SwordNGun/Private/Characters/SNGCharacterBase.cpp b/SwordNGun/Source/SwordNGun/Private/Characters/SNGCharacterBase.cpp index f70dda7..af4f60a 100644 --- a/SwordNGun/Source/SwordNGun/Private/Characters/SNGCharacterBase.cpp +++ b/SwordNGun/Source/SwordNGun/Private/Characters/SNGCharacterBase.cpp @@ -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); } diff --git a/SwordNGun/Source/SwordNGun/Public/Characters/SNGCharacterBase.h b/SwordNGun/Source/SwordNGun/Public/Characters/SNGCharacterBase.h index 450639c..85360d0 100644 --- a/SwordNGun/Source/SwordNGun/Public/Characters/SNGCharacterBase.h +++ b/SwordNGun/Source/SwordNGun/Public/Characters/SNGCharacterBase.h @@ -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;