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
|
// Set up randomness
|
||||||
const int32 RandomSeed = FMath::Rand();
|
const int32 RandomSeed = FMath::Rand();
|
||||||
FRandomStream WeaponRandomStream(RandomSeed);
|
FRandomStream WeaponRandomStream(RandomSeed);
|
||||||
const float Spread = CurrentWeapon->GetWeaponProperties()->WeaponSpread;
|
const float Spread = CurrentWeapon->GetWeaponProperties()->WeaponSpread * WeaponSpreadMultiplier;
|
||||||
const float Range = CurrentWeapon->GetWeaponProperties()->ProjectileRange;
|
const float Range = CurrentWeapon->GetWeaponProperties()->ProjectileRange;
|
||||||
|
|
||||||
FVector CamStart = CameraComponent->GetComponentTransform().GetLocation();
|
FVector CamStart = CameraComponent->GetComponentTransform().GetLocation();
|
||||||
|
@ -419,6 +419,11 @@ void APlayerCharacter::BeginAimDownSightsCallback(const FInputActionInstance& In
|
||||||
|
|
||||||
AimSensitivity = DefaultAimSensitivity * ADSAimSensitivityMultiplier;
|
AimSensitivity = DefaultAimSensitivity * ADSAimSensitivityMultiplier;
|
||||||
|
|
||||||
|
if (CurrentWeapon)
|
||||||
|
{
|
||||||
|
WeaponSpreadMultiplier = CurrentWeapon->GetWeaponProperties()->ADSWeaponSpreadMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
FLatentActionInfo LatentActionInfo;
|
FLatentActionInfo LatentActionInfo;
|
||||||
LatentActionInfo.CallbackTarget = this;
|
LatentActionInfo.CallbackTarget = this;
|
||||||
CameraComponent->AttachToComponent(CameraADSSpringArmComponent, FAttachmentTransformRules::KeepWorldTransform,
|
CameraComponent->AttachToComponent(CameraADSSpringArmComponent, FAttachmentTransformRules::KeepWorldTransform,
|
||||||
|
@ -437,6 +442,8 @@ void APlayerCharacter::EndAimDownSightsCallback(const FInputActionInstance& Inst
|
||||||
|
|
||||||
AimSensitivity = DefaultAimSensitivity;
|
AimSensitivity = DefaultAimSensitivity;
|
||||||
|
|
||||||
|
WeaponSpreadMultiplier = 1.0f;
|
||||||
|
|
||||||
FLatentActionInfo LatentActionInfo;
|
FLatentActionInfo LatentActionInfo;
|
||||||
LatentActionInfo.CallbackTarget = this;
|
LatentActionInfo.CallbackTarget = this;
|
||||||
CameraComponent->AttachToComponent(CameraSpringArmComponent, FAttachmentTransformRules::KeepWorldTransform,
|
CameraComponent->AttachToComponent(CameraSpringArmComponent, FAttachmentTransformRules::KeepWorldTransform,
|
||||||
|
|
|
@ -106,6 +106,8 @@ private:
|
||||||
|
|
||||||
float AimSensitivity;
|
float AimSensitivity;
|
||||||
|
|
||||||
|
float WeaponSpreadMultiplier = 1.0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Sets default values for this character's properties
|
// Sets default values for this character's properties
|
||||||
APlayerCharacter();
|
APlayerCharacter();
|
||||||
|
|
|
@ -38,6 +38,9 @@ struct FWeaponProperties
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
||||||
float WeaponSpread = 2.5f;
|
float WeaponSpread = 2.5f;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
||||||
|
float ADSWeaponSpreadMultiplier = 0.5f;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
||||||
bool IsAutomatic = true;
|
bool IsAutomatic = true;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue