fix: improved recoil
Recoil now based on camera move instead of applying forces on player character
This commit is contained in:
parent
0f2fac10bd
commit
c26dcd6eae
|
|
@ -51,8 +51,11 @@ void UShootingComponent::Shoot()
|
||||||
PlayerCharacter->GetWorldTimerManager().SetTimer(ShootCooldownTimer, this, &UShootingComponent::ResetFireCooldown, FireRateCooldown, false);
|
PlayerCharacter->GetWorldTimerManager().SetTimer(ShootCooldownTimer, this, &UShootingComponent::ResetFireCooldown, FireRateCooldown, false);
|
||||||
|
|
||||||
// Odrzut
|
// Odrzut
|
||||||
FVector RecoilDirection = -PlayerCharacter->GetActorForwardVector();
|
float RecoilPitch = FMath::RandRange(-1.0f, -0.5f);
|
||||||
PlayerCharacter->LaunchCharacter(RecoilDirection * RecoilForce, true, false);
|
float RecoilYaw = FMath::RandRange(-0.5f, 0.5f);
|
||||||
|
|
||||||
|
PlayerCharacter->AddControllerPitchInput(RecoilPitch * RecoilForceMultiplier);
|
||||||
|
PlayerCharacter->AddControllerYawInput(RecoilYaw * RecoilForceMultiplier);
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
if (bShowDebugLine)
|
if (bShowDebugLine)
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public:
|
||||||
float FireRateCooldown = 1.0f;
|
float FireRateCooldown = 1.0f;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Shooting")
|
UPROPERTY(EditAnywhere, Category = "Shooting")
|
||||||
float RecoilForce = 50.0f;
|
float RecoilForceMultiplier = 1.0f;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Shooting")
|
UPROPERTY(EditAnywhere, Category = "Shooting")
|
||||||
float ReloadTime = 3.0f;
|
float ReloadTime = 3.0f;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user