Add ADS aim sensitivity modifier
This commit is contained in:
parent
3d4ef7e3c0
commit
938b4425eb
|
@ -72,6 +72,8 @@ void APlayerCharacter::BeginPlay()
|
||||||
|
|
||||||
DefaultMovementSpeed = GetCharacterMovement()->MaxWalkSpeed;
|
DefaultMovementSpeed = GetCharacterMovement()->MaxWalkSpeed;
|
||||||
|
|
||||||
|
AimSensitivity = DefaultAimSensitivity;
|
||||||
|
|
||||||
if (!this->ActorHasTag(FName("Player")))
|
if (!this->ActorHasTag(FName("Player")))
|
||||||
{
|
{
|
||||||
this->Tags.Add(FName("Player"));
|
this->Tags.Add(FName("Player"));
|
||||||
|
@ -187,8 +189,8 @@ void APlayerCharacter::LookCallback(const FInputActionInstance& Instance)
|
||||||
|
|
||||||
if (vec2.Size() != 0.0f)
|
if (vec2.Size() != 0.0f)
|
||||||
{
|
{
|
||||||
AddControllerYawInput(vec2.X * 45.0f * GetWorld()->GetDeltaSeconds());
|
AddControllerYawInput(vec2.X * AimSensitivity * GetWorld()->GetDeltaSeconds());
|
||||||
AddControllerPitchInput((vec2.Y * (-1.0f)) * 45.0f * GetWorld()->GetDeltaSeconds());
|
AddControllerPitchInput((vec2.Y * (-1.0f)) * AimSensitivity * GetWorld()->GetDeltaSeconds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,6 +417,8 @@ void APlayerCharacter::BeginAimDownSightsCallback(const FInputActionInstance& In
|
||||||
|
|
||||||
SetMovementSpeed();
|
SetMovementSpeed();
|
||||||
|
|
||||||
|
AimSensitivity = DefaultAimSensitivity * ADSAimSensitivityMultiplier;
|
||||||
|
|
||||||
FLatentActionInfo LatentActionInfo;
|
FLatentActionInfo LatentActionInfo;
|
||||||
LatentActionInfo.CallbackTarget = this;
|
LatentActionInfo.CallbackTarget = this;
|
||||||
CameraComponent->AttachToComponent(CameraADSSpringArmComponent, FAttachmentTransformRules::KeepWorldTransform,
|
CameraComponent->AttachToComponent(CameraADSSpringArmComponent, FAttachmentTransformRules::KeepWorldTransform,
|
||||||
|
@ -431,6 +435,8 @@ void APlayerCharacter::EndAimDownSightsCallback(const FInputActionInstance& Inst
|
||||||
|
|
||||||
SetMovementSpeed();
|
SetMovementSpeed();
|
||||||
|
|
||||||
|
AimSensitivity = DefaultAimSensitivity;
|
||||||
|
|
||||||
FLatentActionInfo LatentActionInfo;
|
FLatentActionInfo LatentActionInfo;
|
||||||
LatentActionInfo.CallbackTarget = this;
|
LatentActionInfo.CallbackTarget = this;
|
||||||
CameraComponent->AttachToComponent(CameraSpringArmComponent, FAttachmentTransformRules::KeepWorldTransform,
|
CameraComponent->AttachToComponent(CameraSpringArmComponent, FAttachmentTransformRules::KeepWorldTransform,
|
||||||
|
|
|
@ -68,9 +68,15 @@ protected:
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
float ADSSpeedMultiplier = 0.5f;
|
float ADSSpeedMultiplier = 0.5f;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
|
float ADSAimSensitivityMultiplier = 0.5f;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
float CameraBlendTime = 0.1f;
|
float CameraBlendTime = 0.1f;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
|
float DefaultAimSensitivity = 45.0f;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true"))
|
||||||
USpringArmComponent* CameraSpringArmComponent = nullptr;
|
USpringArmComponent* CameraSpringArmComponent = nullptr;
|
||||||
|
@ -97,6 +103,8 @@ private:
|
||||||
bool IsSpriting = false;
|
bool IsSpriting = false;
|
||||||
|
|
||||||
bool IsADS = false;
|
bool IsADS = false;
|
||||||
|
|
||||||
|
float AimSensitivity;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Sets default values for this character's properties
|
// Sets default values for this character's properties
|
||||||
|
|
Loading…
Reference in New Issue