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
|
// Set up randomness
|
||||||
const int32 RandomSeed = FMath::Rand();
|
const int32 RandomSeed = FMath::Rand();
|
||||||
FRandomStream WeaponRandomStream(RandomSeed);
|
FRandomStream WeaponRandomStream(RandomSeed);
|
||||||
const float Spread = 1.0f; // TODO: Replace with a more sensible value later
|
const float Spread = CurrentWeapon->GetWeaponProperties()->WeaponSpread;
|
||||||
const float Range = 50000.f; // TODO: Replace with a more sensible value later
|
const float Range = CurrentWeapon->GetWeaponProperties()->ProjectileRange;
|
||||||
|
|
||||||
// Calculate starting position and direction
|
// Calculate starting position and direction
|
||||||
FVector TraceStart;
|
FVector TraceStart;
|
||||||
|
@ -207,11 +207,14 @@ void APlayerCharacter::CalculateHits(TArray<FHitResult>* hits)
|
||||||
// Calculate the hit results from the trace
|
// Calculate the hit results from the trace
|
||||||
TArray<FHitResult> HitResults;
|
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());
|
FCollisionQueryParams TraceParams(SCENE_QUERY_STAT(WeaponTrace), true, GetInstigator());
|
||||||
TraceParams.bReturnPhysicalMaterial = true;
|
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 ShootDir = WeaponRandomStream.VRandCone(AimDir, FMath::DegreesToRadians(Spread), FMath::DegreesToRadians(Spread));
|
||||||
FVector MaxHitLoc = TraceStart + (ShootDir * Range);
|
FVector MaxHitLoc = TraceStart + (ShootDir * Range);
|
||||||
|
|
||||||
|
@ -225,6 +228,7 @@ void APlayerCharacter::CalculateHits(TArray<FHitResult>* hits)
|
||||||
// TODO: Handle hits in a meaningful way
|
// TODO: Handle hits in a meaningful way
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void APlayerCharacter::SetInventoryToDefault()
|
void APlayerCharacter::SetInventoryToDefault()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue