Use`CurrentWeapon` properties in `CalculateHits`
This commit is contained in:
parent
4712d405d5
commit
3007c56580
|
@ -192,8 +192,8 @@ void APlayerCharacter::CalculateHits(TArray<FHitResult>* hits)
|
|||
// Set up randomness
|
||||
const int32 RandomSeed = FMath::Rand();
|
||||
FRandomStream WeaponRandomStream(RandomSeed);
|
||||
const float Spread = 1.0f; // TODO: Replace with a more sensible value later
|
||||
const float Range = 50000.f; // TODO: Replace with a more sensible value later
|
||||
const float Spread = CurrentWeapon->GetWeaponProperties()->WeaponSpread;
|
||||
const float Range = CurrentWeapon->GetWeaponProperties()->ProjectileRange;
|
||||
|
||||
// Calculate starting position and direction
|
||||
FVector TraceStart;
|
||||
|
@ -207,11 +207,14 @@ void APlayerCharacter::CalculateHits(TArray<FHitResult>* hits)
|
|||
// Calculate the hit results from the trace
|
||||
TArray<FHitResult> HitResults;
|
||||
|
||||
/// Set up the collision query params, use the Weapon trace settings, Ignore the actor firing this trace
|
||||
// Set up the collision query params, use the Weapon trace settings, Ignore the actor firing this trace
|
||||
FCollisionQueryParams TraceParams(SCENE_QUERY_STAT(WeaponTrace), true, GetInstigator());
|
||||
TraceParams.bReturnPhysicalMaterial = true;
|
||||
|
||||
/// Calculate the maximum distance the weapon can fire
|
||||
|
||||
for (size_t i = 0; i < CurrentWeapon->GetWeaponProperties()->ProjectilesPerShot; i++)
|
||||
{
|
||||
// Calculate the maximum distance the weapon can fire
|
||||
FVector ShootDir = WeaponRandomStream.VRandCone(AimDir, FMath::DegreesToRadians(Spread), FMath::DegreesToRadians(Spread));
|
||||
FVector MaxHitLoc = TraceStart + (ShootDir * Range);
|
||||
|
||||
|
@ -224,6 +227,7 @@ void APlayerCharacter::CalculateHits(TArray<FHitResult>* hits)
|
|||
|
||||
// TODO: Handle hits in a meaningful way
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void APlayerCharacter::SetInventoryToDefault()
|
||||
|
|
Loading…
Reference in New Issue