Fixed Player BP Issues

This commit is contained in:
Rafal Swierczek 2024-03-17 19:32:07 +00:00
parent 0b12f2e0df
commit 3633e1fe24
7 changed files with 60 additions and 50 deletions

View File

@ -173,12 +173,18 @@ void ABaseWeaponClass::CancelFire()
void ABaseWeaponClass::Fire() void ABaseWeaponClass::Fire()
{ {
if (currentAmmoCount > 0) if (currentAmmoCount <= 0)
{ {
//do damage fallof based off distance UE_LOG(LogTemp, Display, TEXT("No ammo, Ammo count: %d"), currentAmmoCount);
traceStart = Cast<USkeletalMeshComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass()))->GetSocketLocation("Muzzle"); ShowNeedReloadUI();
traceEnd = traceStart + Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn())->GetFirstPersonCameraComponent()->GetForwardVector() * BulletDistance; return;
}
if (GetWorldTimerManager().IsTimerActive(timerHandle)) return; if (GetWorldTimerManager().IsTimerActive(timerHandle)) return;
//do damage fallof based off distance
UCameraComponent* CamComp = Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn())->GetFirstPersonCameraComponent();
traceStart = Cast<USkeletalMeshComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass()))->GetSocketLocation("Muzzle");
traceEnd = CamComp->GetComponentLocation() + CamComp->GetForwardVector() * BulletDistance;
FCollisionObjectQueryParams ObjectQueryParams; FCollisionObjectQueryParams ObjectQueryParams;
ObjectQueryParams.AddObjectTypesToQuery(ECC_Pawn); ObjectQueryParams.AddObjectTypesToQuery(ECC_Pawn);
ObjectQueryParams.AddObjectTypesToQuery(ECC_WorldStatic); ObjectQueryParams.AddObjectTypesToQuery(ECC_WorldStatic);
@ -221,12 +227,7 @@ void ABaseWeaponClass::Fire()
} }
} }
HideNeedReloadUI(); HideNeedReloadUI();
}
else if (currentAmmoCount <= 0)
{
UE_LOG(LogTemp, Display, TEXT("No ammo, Ammo count: %d"), currentAmmoCount);
ShowNeedReloadUI();
}
} }
void ABaseWeaponClass::WeaponScopedFire() void ABaseWeaponClass::WeaponScopedFire()