Reimplement Aim Down Sights movement modifiers
This commit is contained in:
parent
ed84a592ef
commit
d758272d9d
BIN
Content/Player/PlayerCharacter.uasset (Stored with Git LFS)
BIN
Content/Player/PlayerCharacter.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -61,6 +61,7 @@ void UNakatomiCMC::FSavedMove_Nakatomi::SetMoveFor(ACharacter* C, float InDeltaT
|
||||||
|
|
||||||
Saved_bWantsToSprint = CharacterMovement->Safe_bWantsToSprint;
|
Saved_bWantsToSprint = CharacterMovement->Safe_bWantsToSprint;
|
||||||
Saved_bWantsToSlide = CharacterMovement->Safe_bWantsToSlide;
|
Saved_bWantsToSlide = CharacterMovement->Safe_bWantsToSlide;
|
||||||
|
Saved_bWantsToAds = CharacterMovement->Safe_bWantsToAds;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UNakatomiCMC::FSavedMove_Nakatomi::PrepMoveFor(ACharacter* C)
|
void UNakatomiCMC::FSavedMove_Nakatomi::PrepMoveFor(ACharacter* C)
|
||||||
|
@ -71,6 +72,7 @@ void UNakatomiCMC::FSavedMove_Nakatomi::PrepMoveFor(ACharacter* C)
|
||||||
|
|
||||||
CharacterMovement->Safe_bWantsToSprint = Saved_bWantsToSprint;
|
CharacterMovement->Safe_bWantsToSprint = Saved_bWantsToSprint;
|
||||||
CharacterMovement->Safe_bWantsToSlide = Saved_bWantsToSlide;
|
CharacterMovement->Safe_bWantsToSlide = Saved_bWantsToSlide;
|
||||||
|
CharacterMovement->Safe_bWantsToAds = Saved_bWantsToAds;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNakatomiCMC::FNetworkPredictionData_Client_Nakatomi::FNetworkPredictionData_Client_Nakatomi(
|
UNakatomiCMC::FNetworkPredictionData_Client_Nakatomi::FNetworkPredictionData_Client_Nakatomi(
|
||||||
|
@ -120,6 +122,23 @@ void UNakatomiCMC::OnMovementUpdated(float DeltaSeconds, const FVector& OldLocat
|
||||||
{
|
{
|
||||||
MaxWalkSpeed = Walk_MaxWalkSpeed;
|
MaxWalkSpeed = Walk_MaxWalkSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Safe_bWantsToAds)
|
||||||
|
{
|
||||||
|
MaxWalkSpeed *= Ads_Multiplier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bWantsToCrouch)
|
||||||
|
{
|
||||||
|
if (Safe_bWantsToAds)
|
||||||
|
{
|
||||||
|
MaxWalkSpeedCrouched = Crouch_MaxWalkSpeed * Ads_Multiplier;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MaxWalkSpeedCrouched = Crouch_MaxWalkSpeed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +154,7 @@ bool UNakatomiCMC::CanCrouchInCurrentState() const
|
||||||
|
|
||||||
void UNakatomiCMC::UpdateCharacterStateBeforeMovement(float DeltaSeconds)
|
void UNakatomiCMC::UpdateCharacterStateBeforeMovement(float DeltaSeconds)
|
||||||
{
|
{
|
||||||
if (MovementMode == MOVE_Walking && Safe_bWantsToSlide)
|
if (MovementMode == MOVE_Walking && Safe_bWantsToSlide && !Safe_bWantsToAds)
|
||||||
{
|
{
|
||||||
FHitResult PotentialSlideSurface;
|
FHitResult PotentialSlideSurface;
|
||||||
if (Velocity.SizeSquared() > pow(Slide_MinSpeed, 2) && GetSlideSurface(PotentialSlideSurface))
|
if (Velocity.SizeSquared() > pow(Slide_MinSpeed, 2) && GetSlideSurface(PotentialSlideSurface))
|
||||||
|
@ -196,6 +215,16 @@ void UNakatomiCMC::DisableSlide()
|
||||||
Safe_bWantsToSlide = false;
|
Safe_bWantsToSlide = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UNakatomiCMC::EnableAds()
|
||||||
|
{
|
||||||
|
Safe_bWantsToAds = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UNakatomiCMC::DisableAds()
|
||||||
|
{
|
||||||
|
Safe_bWantsToAds = false;
|
||||||
|
}
|
||||||
|
|
||||||
bool UNakatomiCMC::IsCustomMovementMode(ECustomMovementMove InCustomMovementMode) const
|
bool UNakatomiCMC::IsCustomMovementMode(ECustomMovementMove InCustomMovementMode) const
|
||||||
{
|
{
|
||||||
return MovementMode == MOVE_Custom && CustomMovementMode == InCustomMovementMode;
|
return MovementMode == MOVE_Custom && CustomMovementMode == InCustomMovementMode;
|
||||||
|
|
|
@ -31,6 +31,8 @@ class NAKATOMI_API UNakatomiCMC : public UCharacterMovementComponent
|
||||||
uint8 Saved_bWantsToSprint:1;
|
uint8 Saved_bWantsToSprint:1;
|
||||||
|
|
||||||
uint8 Saved_bWantsToSlide:1;
|
uint8 Saved_bWantsToSlide:1;
|
||||||
|
|
||||||
|
uint8 Saved_bWantsToAds:1;
|
||||||
|
|
||||||
virtual bool CanCombineWith(const FSavedMovePtr& NewMove, ACharacter* InCharacter, float MaxDelta) const override;
|
virtual bool CanCombineWith(const FSavedMovePtr& NewMove, ACharacter* InCharacter, float MaxDelta) const override;
|
||||||
virtual void Clear() override;
|
virtual void Clear() override;
|
||||||
|
@ -50,11 +52,14 @@ class NAKATOMI_API UNakatomiCMC : public UCharacterMovementComponent
|
||||||
};
|
};
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
float Sprint_MaxWalkSpeed;
|
float Sprint_MaxWalkSpeed = 1000.0f;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
float Walk_MaxWalkSpeed;
|
float Walk_MaxWalkSpeed = 500.0f;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly)
|
||||||
|
float Crouch_MaxWalkSpeed = 250.0f;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
float Slide_MinSpeed = 50.f;
|
float Slide_MinSpeed = 50.f;
|
||||||
|
|
||||||
|
@ -66,10 +71,14 @@ class NAKATOMI_API UNakatomiCMC : public UCharacterMovementComponent
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
float Slide_Friction = 1.f;
|
float Slide_Friction = 1.f;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly)
|
||||||
|
float Ads_Multiplier = 0.5f;
|
||||||
|
|
||||||
bool Safe_bWantsToSprint;
|
bool Safe_bWantsToSprint;
|
||||||
bool Safe_bWantsToSlide;
|
bool Safe_bWantsToSlide;
|
||||||
|
bool Safe_bWantsToAds;
|
||||||
|
|
||||||
UPROPERTY(Transient)
|
UPROPERTY(Transient)
|
||||||
ANakatomiCharacter* NakatomiCharacterOwner;
|
ANakatomiCharacter* NakatomiCharacterOwner;
|
||||||
|
|
||||||
|
@ -112,6 +121,12 @@ public:
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void DisableSlide();
|
void DisableSlide();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void EnableAds();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void DisableAds();
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
bool IsCustomMovementMode(ECustomMovementMove InCustomMovementMode) const;
|
bool IsCustomMovementMode(ECustomMovementMove InCustomMovementMode) const;
|
||||||
|
|
||||||
|
|
|
@ -465,22 +465,6 @@ void APlayerCharacter::OnDeath()
|
||||||
UGameplayStatics::OpenLevel(this, FName(map), false);
|
UGameplayStatics::OpenLevel(this, FName(map), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void APlayerCharacter::SetMovementSpeed()
|
|
||||||
{
|
|
||||||
/*if (IsADS)
|
|
||||||
{
|
|
||||||
GetCharacterMovement()->MaxWalkSpeed = DefaultMovementSpeed * ADSSpeedMultiplier;
|
|
||||||
}
|
|
||||||
else if (IsSpriting)
|
|
||||||
{
|
|
||||||
GetCharacterMovement()->MaxWalkSpeed = DefaultMovementSpeed * SprintSpeedMultiplier;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GetCharacterMovement()->MaxWalkSpeed = DefaultMovementSpeed;
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void APlayerCharacter::WeaponSwitchingCallback(const FInputActionInstance& Instance)
|
void APlayerCharacter::WeaponSwitchingCallback(const FInputActionInstance& Instance)
|
||||||
{
|
{
|
||||||
float value = Instance.GetValue().Get<float>();
|
float value = Instance.GetValue().Get<float>();
|
||||||
|
@ -499,7 +483,12 @@ void APlayerCharacter::BeginAimDownSightsCallback(const FInputActionInstance& In
|
||||||
{
|
{
|
||||||
IsADS = true;
|
IsADS = true;
|
||||||
|
|
||||||
SetMovementSpeed();
|
UNakatomiCMC* cmc = GetCharacterMovementComponent();
|
||||||
|
|
||||||
|
if (cmc)
|
||||||
|
{
|
||||||
|
cmc->EnableAds();
|
||||||
|
}
|
||||||
|
|
||||||
AimSensitivity = DefaultAimSensitivity * ADSAimSensitivityMultiplier;
|
AimSensitivity = DefaultAimSensitivity * ADSAimSensitivityMultiplier;
|
||||||
|
|
||||||
|
@ -522,7 +511,12 @@ void APlayerCharacter::EndAimDownSightsCallback(const FInputActionInstance& Inst
|
||||||
{
|
{
|
||||||
IsADS = false;
|
IsADS = false;
|
||||||
|
|
||||||
SetMovementSpeed();
|
UNakatomiCMC* cmc = GetCharacterMovementComponent();
|
||||||
|
|
||||||
|
if (cmc)
|
||||||
|
{
|
||||||
|
cmc->DisableAds();
|
||||||
|
}
|
||||||
|
|
||||||
AimSensitivity = DefaultAimSensitivity;
|
AimSensitivity = DefaultAimSensitivity;
|
||||||
|
|
||||||
|
|
|
@ -89,9 +89,6 @@ protected:
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
float SprintSpeedMultiplier = 2.0f;
|
float SprintSpeedMultiplier = 2.0f;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
|
||||||
float ADSSpeedMultiplier = 0.5f;
|
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
float ADSAimSensitivityMultiplier = 0.5f;
|
float ADSAimSensitivityMultiplier = 0.5f;
|
||||||
|
|
||||||
|
@ -224,6 +221,5 @@ protected:
|
||||||
virtual void OnDamaged() override;
|
virtual void OnDamaged() override;
|
||||||
|
|
||||||
virtual void OnDeath() override;
|
virtual void OnDeath() override;
|
||||||
|
|
||||||
void SetMovementSpeed();
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue