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);
|
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
|
float amplitude = RecoilCurve->GetFloatValue(recoilTime); //get current value of curve in time
|
||||||
recoilTime += DeltaTime;
|
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));
|
GunStartArrow->AddRelativeRotation(FRotator(-GetRecoilPitch(amplitude, recoilTime), 0, 0));
|
||||||
playerInWorld->AddControllerYawInput(GetRecoilYaw(amplitude, recoilTime));
|
playerInWorld->AddControllerYawInput(GetRecoilYaw(amplitude, recoilTime));
|
||||||
UpdateSamples(amplitude, recoilTime);
|
UpdateSamples(amplitude, recoilTime);
|
||||||
@ -144,10 +155,13 @@ void ABaseWeaponClass::ClickDetectionTimer()
|
|||||||
void ABaseWeaponClass::CancelFire()
|
void ABaseWeaponClass::CancelFire()
|
||||||
{
|
{
|
||||||
GetWorldTimerManager().ClearTimer(timerHandle);
|
GetWorldTimerManager().ClearTimer(timerHandle);
|
||||||
|
if (bulletCountShoot <= 0) return;
|
||||||
UE_LOG(LogTemp, Display, TEXT("FireCancelled"));
|
UE_LOG(LogTemp, Display, TEXT("FireCancelled"));
|
||||||
bulletCountShoot = 0;
|
bulletCountShoot = 0;
|
||||||
GunStartArrow->SetRelativeRotation(FRotator(0,0,0));
|
GunStartArrow->SetRelativeRotation(FRotator(0));
|
||||||
playerControllerRef->SetControlRotation(FRotator(0,0,0));
|
//playerInWorld->GetController()->SetControlRotation(FRotator(0, playerInWorld->GetActorRotation().Yaw, playerInWorld->GetActorRotation().Roll));
|
||||||
|
bStopShooting = true;
|
||||||
|
nullSamples();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ABaseWeaponClass::Fire()
|
void ABaseWeaponClass::Fire()
|
||||||
@ -165,6 +179,7 @@ void ABaseWeaponClass::Fire()
|
|||||||
GenerateRecoilVector();
|
GenerateRecoilVector();
|
||||||
ClickDetectionTimer();
|
ClickDetectionTimer();
|
||||||
bulletCountShoot += 1;
|
bulletCountShoot += 1;
|
||||||
|
bStopShooting = false;
|
||||||
if (outHit.bBlockingHit)
|
if (outHit.bBlockingHit)
|
||||||
{
|
{
|
||||||
if (!Cast<AAICharacter>(outHit.GetActor())) return;
|
if (!Cast<AAICharacter>(outHit.GetActor())) return;
|
||||||
|
@ -154,5 +154,7 @@ private:
|
|||||||
float originalMinMultiplier;
|
float originalMinMultiplier;
|
||||||
|
|
||||||
int currentAmmoCount;
|
int currentAmmoCount;
|
||||||
|
|
||||||
|
float currentPitch;
|
||||||
|
bool bStopShooting = false;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user