feat: add slide
Executing when player press crouch button (Ctrl) when sprinting (hold Shift)
This commit is contained in:
parent
674a294f9c
commit
797ec44907
Binary file not shown.
|
|
@ -134,6 +134,12 @@ void AExoPlayerController::ResetDodge()
|
||||||
|
|
||||||
void AExoPlayerController::PlayerStartCrouch()
|
void AExoPlayerController::PlayerStartCrouch()
|
||||||
{
|
{
|
||||||
|
if (bIsSprinting)
|
||||||
|
{
|
||||||
|
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeedCrouched = PlayerCharacter->SlideSpeed;
|
||||||
|
GetWorldTimerManager().SetTimer(SlideCooldownTimer, this, &AExoPlayerController::ResetSlide, PlayerCharacter->SlideCooldown, false);
|
||||||
|
}
|
||||||
|
|
||||||
PlayerCharacter->Crouch();
|
PlayerCharacter->Crouch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,12 +148,18 @@ void AExoPlayerController::PlayerStopCrouch()
|
||||||
PlayerCharacter->UnCrouch();
|
PlayerCharacter->UnCrouch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AExoPlayerController::ResetSlide()
|
||||||
|
{
|
||||||
|
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeedCrouched = PlayerCharacter->CrouchSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
void AExoPlayerController::PlayerStartSprint()
|
void AExoPlayerController::PlayerStartSprint()
|
||||||
{
|
{
|
||||||
if (!PlayerCharacter->bIsAimingMode)
|
if (!PlayerCharacter->bIsAimingMode)
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Display, TEXT("Start sprint"));
|
UE_LOG(LogTemp, Display, TEXT("Start sprint"));
|
||||||
|
|
||||||
|
bIsSprinting = true;
|
||||||
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->SprintSpeed;
|
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->SprintSpeed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -158,6 +170,7 @@ void AExoPlayerController::PlayerStopSprint()
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Display, TEXT("Stop sprint"));
|
UE_LOG(LogTemp, Display, TEXT("Stop sprint"));
|
||||||
|
|
||||||
|
bIsSprinting = false;
|
||||||
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed;
|
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,20 @@ public:
|
||||||
UPROPERTY(EditAnywhere, Category = "Dodge Properties")
|
UPROPERTY(EditAnywhere, Category = "Dodge Properties")
|
||||||
float DodgeCooldown = 2.f;
|
float DodgeCooldown = 2.f;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Slide Properties")
|
||||||
|
float SlideCooldown = 0.35f;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Movement Properties")
|
UPROPERTY(EditAnywhere, Category = "Movement Properties")
|
||||||
float WalkSpeed = 600.0f;
|
float WalkSpeed = 600.0f;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Movement Properties")
|
UPROPERTY(EditAnywhere, Category = "Movement Properties")
|
||||||
float SprintSpeed = 1500.0f;
|
float SprintSpeed = 1500.0f;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Movement Properties")
|
||||||
|
float SlideSpeed = 2500.f;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Movement Properties")
|
||||||
|
float CrouchSpeed = 300.f;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Aiming")
|
UPROPERTY(EditAnywhere, Category = "Aiming")
|
||||||
float bIsAimingMode = false;
|
float bIsAimingMode = false;
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,9 @@ protected:
|
||||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||||
void PlayerStopCrouch(); // LCtrl\C\X
|
void PlayerStopCrouch(); // LCtrl\C\X
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||||
|
void ResetSlide();
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||||
void PlayerStartSprint(); // LShift(Hold)
|
void PlayerStartSprint(); // LShift(Hold)
|
||||||
|
|
||||||
|
|
@ -114,11 +117,17 @@ protected:
|
||||||
UPROPERTY(EditAnywhere, Category = "Input")
|
UPROPERTY(EditAnywhere, Category = "Input")
|
||||||
TObjectPtr<UInputAction> DodgeAction;
|
TObjectPtr<UInputAction> DodgeAction;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Dodge Properties")
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Movement Properties")
|
||||||
FTimerHandle DodgeCooldownTimer;
|
FTimerHandle DodgeCooldownTimer;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Dodge Properties")
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Movement Properties")
|
||||||
|
FTimerHandle SlideCooldownTimer;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Movement Properties")
|
||||||
bool CanDodge = true;
|
bool CanDodge = true;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Movement properties")
|
||||||
|
bool bIsSprinting = false;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Input")
|
UPROPERTY(EditAnywhere, Category = "Input")
|
||||||
TObjectPtr<UInputAction> ShootAction;
|
TObjectPtr<UInputAction> ShootAction;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user