diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp index 271d8234..e348490a 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp @@ -63,6 +63,13 @@ void ABaseWeaponClass::Tick(float DeltaTime) { ApplyRecoil(DeltaTime); } + UE_LOG(LogTemp, Display, TEXT("currnt pitch: %f"), currentPitch); + if (currentPitch < 0 && bStopShooting) + { + float increment = currentPitch * DeltaTime * 8; + currentPitch -= increment; + playerInWorld->AddControllerPitchInput(-increment); + } } @@ -94,7 +101,11 @@ void ABaseWeaponClass::ApplyRecoil(float DeltaTime) { float amplitude = RecoilCurve->GetFloatValue(recoilTime); //get current value of curve in time recoilTime += DeltaTime; - if (bulletCountShoot <= 3) playerInWorld->AddControllerPitchInput(GetRecoilPitch(amplitude, recoilTime)); + if (bulletCountShoot <= 3) + { + playerInWorld->AddControllerPitchInput(GetRecoilPitch(amplitude, recoilTime)); + currentPitch += GetRecoilPitch(amplitude,recoilTime); + } GunStartArrow->AddRelativeRotation(FRotator(-GetRecoilPitch(amplitude, recoilTime), 0, 0)); playerInWorld->AddControllerYawInput(GetRecoilYaw(amplitude, recoilTime)); UpdateSamples(amplitude, recoilTime); @@ -144,10 +155,13 @@ void ABaseWeaponClass::ClickDetectionTimer() void ABaseWeaponClass::CancelFire() { GetWorldTimerManager().ClearTimer(timerHandle); + if (bulletCountShoot <= 0) return; UE_LOG(LogTemp, Display, TEXT("FireCancelled")); bulletCountShoot = 0; - GunStartArrow->SetRelativeRotation(FRotator(0,0,0)); - playerControllerRef->SetControlRotation(FRotator(0,0,0)); + GunStartArrow->SetRelativeRotation(FRotator(0)); + //playerInWorld->GetController()->SetControlRotation(FRotator(0, playerInWorld->GetActorRotation().Yaw, playerInWorld->GetActorRotation().Roll)); + bStopShooting = true; + nullSamples(); } void ABaseWeaponClass::Fire() @@ -165,6 +179,7 @@ void ABaseWeaponClass::Fire() GenerateRecoilVector(); ClickDetectionTimer(); bulletCountShoot += 1; + bStopShooting = false; if (outHit.bBlockingHit) { if (!Cast(outHit.GetActor())) return; diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h index 98557014..6647f0d6 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h @@ -154,5 +154,7 @@ private: float originalMinMultiplier; int currentAmmoCount; - + + float currentPitch; + bool bStopShooting = false; };