Fixed camera returning to correct position
This commit is contained in:
parent
79ef9a3de1
commit
9e09c569db
@ -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<AAICharacter>(outHit.GetActor())) return;
|
||||
|
@ -155,4 +155,6 @@ private:
|
||||
|
||||
int currentAmmoCount;
|
||||
|
||||
float currentPitch;
|
||||
bool bStopShooting = false;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user