fix: improved recoil

Recoil now based on camera move instead of applying forces on player character
This commit is contained in:
Kubson96 2025-02-22 20:33:07 +01:00
parent 0f2fac10bd
commit c26dcd6eae
2 changed files with 6 additions and 3 deletions

View File

@ -51,8 +51,11 @@ void UShootingComponent::Shoot()
PlayerCharacter->GetWorldTimerManager().SetTimer(ShootCooldownTimer, this, &UShootingComponent::ResetFireCooldown, FireRateCooldown, false);
// Odrzut
FVector RecoilDirection = -PlayerCharacter->GetActorForwardVector();
PlayerCharacter->LaunchCharacter(RecoilDirection * RecoilForce, true, false);
float RecoilPitch = FMath::RandRange(-1.0f, -0.5f);
float RecoilYaw = FMath::RandRange(-0.5f, 0.5f);
PlayerCharacter->AddControllerPitchInput(RecoilPitch * RecoilForceMultiplier);
PlayerCharacter->AddControllerYawInput(RecoilYaw * RecoilForceMultiplier);
// DEBUG
if (bShowDebugLine)

View File

@ -28,7 +28,7 @@ public:
float FireRateCooldown = 1.0f;
UPROPERTY(EditAnywhere, Category = "Shooting")
float RecoilForce = 50.0f;
float RecoilForceMultiplier = 1.0f;
UPROPERTY(EditAnywhere, Category = "Shooting")
float ReloadTime = 3.0f;