Implemented weapon switch scroll limit
Signed-off-by: TjgL <lithmoneo@gmail.com>
This commit is contained in:
parent
c50a120cac
commit
e797ecd8de
BIN
Content/Legumix/Player/BP_PlayerController.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Player/BP_PlayerController.uasset
(Stored with Git LFS)
Binary file not shown.
@ -35,6 +35,7 @@ void ALMPlayerController::SetupInputComponent()
|
|||||||
Input->BindAction(FireAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Fire);
|
Input->BindAction(FireAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Fire);
|
||||||
Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload);
|
Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload);
|
||||||
Input->BindAction(ScrollAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Scroll);
|
Input->BindAction(ScrollAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Scroll);
|
||||||
|
Input->BindAction(ScrollAction, ETriggerEvent::Canceled, this, &ALMPlayerController::ScrollEnded);
|
||||||
Input->BindAction(PauseAction, ETriggerEvent::Triggered, this, &ALMPlayerController::TogglePause);
|
Input->BindAction(PauseAction, ETriggerEvent::Triggered, this, &ALMPlayerController::TogglePause);
|
||||||
Input->BindAction(SlideAction, ETriggerEvent::Started, this, &ALMPlayerController::SlideInput);
|
Input->BindAction(SlideAction, ETriggerEvent::Started, this, &ALMPlayerController::SlideInput);
|
||||||
Input->BindAction(SlideAction, ETriggerEvent::Completed, this, &ALMPlayerController::SlideCancel);
|
Input->BindAction(SlideAction, ETriggerEvent::Completed, this, &ALMPlayerController::SlideCancel);
|
||||||
@ -73,8 +74,19 @@ void ALMPlayerController::Reload(const FInputActionValue& InputValue)
|
|||||||
|
|
||||||
void ALMPlayerController::Scroll(const FInputActionValue& InputValue)
|
void ALMPlayerController::Scroll(const FInputActionValue& InputValue)
|
||||||
{
|
{
|
||||||
|
if (bIsScrolling)
|
||||||
|
return;
|
||||||
|
|
||||||
const float ScrollAmount = InputValue.Get<float>();
|
const float ScrollAmount = InputValue.Get<float>();
|
||||||
LegumixPlayer->GetWeaponManager()->SwitchWeapon(ScrollAmount);
|
LegumixPlayer->GetWeaponManager()->SwitchWeapon(ScrollAmount);
|
||||||
|
bIsScrolling = true;
|
||||||
|
GetWorldTimerManager().SetTimer(ScrollTimer, this, &ALMPlayerController::ScrollEnded, SwitchWeaponDelay, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ALMPlayerController::ScrollEnded()
|
||||||
|
{
|
||||||
|
GetWorldTimerManager().ClearTimer(ScrollTimer);
|
||||||
|
bIsScrolling = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ALMPlayerController::PauseInput(const FInputActionValue& InputValue)
|
void ALMPlayerController::PauseInput(const FInputActionValue& InputValue)
|
||||||
|
@ -54,7 +54,6 @@ private:
|
|||||||
UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||||
TObjectPtr<ALMPlayer> LegumixPlayer;
|
TObjectPtr<ALMPlayer> LegumixPlayer;
|
||||||
|
|
||||||
|
|
||||||
virtual void SetupInputComponent() override;
|
virtual void SetupInputComponent() override;
|
||||||
void Move(const FInputActionValue& InputValue);
|
void Move(const FInputActionValue& InputValue);
|
||||||
void Jump(const FInputActionValue& InputValue);
|
void Jump(const FInputActionValue& InputValue);
|
||||||
@ -69,10 +68,19 @@ private:
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true, UIMin=0.01, ClampMin=0.01, UIMax=10.0, ClampMax=10.0))
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true, UIMin=0.01, ClampMin=0.01, UIMax=10.0, ClampMax=10.0))
|
||||||
float Sensitivity = 1.0f;
|
float Sensitivity = 1.0f;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true, ClampMin = 0.f))
|
||||||
|
float SwitchWeaponDelay = 0.1f;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UFUNCTION(BlueprintCallable, Category = Legumix)
|
UFUNCTION(BlueprintCallable, Category = Legumix)
|
||||||
void TogglePause();
|
void TogglePause();
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = Legumix)
|
UFUNCTION(BlueprintCallable, Category = Legumix)
|
||||||
void OnSettingsChanged();
|
void OnSettingsChanged();
|
||||||
|
|
||||||
|
void ScrollEnded();
|
||||||
|
|
||||||
|
FTimerHandle ScrollTimer;
|
||||||
|
bool bIsScrolling;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user