Add logic to throw weapon once weapon ammo is depleted
This commit is contained in:
parent
7f4de48fb0
commit
12db67439f
|
@ -219,6 +219,12 @@ void APlayerCharacter::BeginFireCallback(const FInputActionInstance& Instance)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CurrentWeapon->GetAmmoCount() == 0)
|
||||||
|
{
|
||||||
|
ThrowWeaponCallback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
IsFiring = true;
|
IsFiring = true;
|
||||||
|
|
||||||
OnFire();
|
OnFire();
|
||||||
|
@ -478,7 +484,7 @@ void APlayerCharacter::EndAimDownSightsCallback(const FInputActionInstance& Inst
|
||||||
|
|
||||||
void APlayerCharacter::OnFire()
|
void APlayerCharacter::OnFire()
|
||||||
{
|
{
|
||||||
if (!IsFiring)
|
if (!IsFiring || CurrentWeapon->GetAmmoCount() == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -497,11 +503,6 @@ void APlayerCharacter::OnFire()
|
||||||
|
|
||||||
CurrentWeapon->SetCurrentWeaponStatus(Cooldown);
|
CurrentWeapon->SetCurrentWeaponStatus(Cooldown);
|
||||||
|
|
||||||
if (CurrentWeapon->GetAmmoCount() == 0)
|
|
||||||
{
|
|
||||||
RemoveCurrentWeaponFromInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
Super::OnFire();
|
Super::OnFire();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,6 +593,8 @@ void APlayerCharacter::ThrowWeaponCallback()
|
||||||
|
|
||||||
Throwable->SetWeaponSkeletalMesh(GetCurrentWeapon()->GetSkeletalMesh());
|
Throwable->SetWeaponSkeletalMesh(GetCurrentWeapon()->GetSkeletalMesh());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemoveCurrentWeaponFromInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
void APlayerCharacter::ThrowExplosiveCallback()
|
void APlayerCharacter::ThrowExplosiveCallback()
|
||||||
|
|
Loading…
Reference in New Issue