Add ADS Weapon Spread Modifier

This commit is contained in:
Louis Hobbs 2023-07-27 22:22:14 +01:00
parent 938b4425eb
commit 929eca3204
3 changed files with 13 additions and 1 deletions

View File

@ -265,7 +265,7 @@ void APlayerCharacter::CalculateHits(TArray<FHitResult>* hits)
// Set up randomness
const int32 RandomSeed = FMath::Rand();
FRandomStream WeaponRandomStream(RandomSeed);
const float Spread = CurrentWeapon->GetWeaponProperties()->WeaponSpread;
const float Spread = CurrentWeapon->GetWeaponProperties()->WeaponSpread * WeaponSpreadMultiplier;
const float Range = CurrentWeapon->GetWeaponProperties()->ProjectileRange;
FVector CamStart = CameraComponent->GetComponentTransform().GetLocation();
@ -419,6 +419,11 @@ void APlayerCharacter::BeginAimDownSightsCallback(const FInputActionInstance& In
AimSensitivity = DefaultAimSensitivity * ADSAimSensitivityMultiplier;
if (CurrentWeapon)
{
WeaponSpreadMultiplier = CurrentWeapon->GetWeaponProperties()->ADSWeaponSpreadMultiplier;
}
FLatentActionInfo LatentActionInfo;
LatentActionInfo.CallbackTarget = this;
CameraComponent->AttachToComponent(CameraADSSpringArmComponent, FAttachmentTransformRules::KeepWorldTransform,
@ -437,6 +442,8 @@ void APlayerCharacter::EndAimDownSightsCallback(const FInputActionInstance& Inst
AimSensitivity = DefaultAimSensitivity;
WeaponSpreadMultiplier = 1.0f;
FLatentActionInfo LatentActionInfo;
LatentActionInfo.CallbackTarget = this;
CameraComponent->AttachToComponent(CameraSpringArmComponent, FAttachmentTransformRules::KeepWorldTransform,

View File

@ -105,6 +105,8 @@ private:
bool IsADS = false;
float AimSensitivity;
float WeaponSpreadMultiplier = 1.0;
public:
// Sets default values for this character's properties

View File

@ -38,6 +38,9 @@ struct FWeaponProperties
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
float WeaponSpread = 2.5f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
float ADSWeaponSpreadMultiplier = 0.5f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
bool IsAutomatic = true;
};