Add ADS Weapon Spread Modifier
This commit is contained in:
parent
938b4425eb
commit
929eca3204
|
@ -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,
|
||||
|
|
|
@ -106,6 +106,8 @@ private:
|
|||
|
||||
float AimSensitivity;
|
||||
|
||||
float WeaponSpreadMultiplier = 1.0;
|
||||
|
||||
public:
|
||||
// Sets default values for this character's properties
|
||||
APlayerCharacter();
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue