Collect move axis and look rot input

This commit is contained in:
Kevin Poretti 2023-11-06 21:29:13 -05:00
parent d53fba996a
commit b62a8cebb6
5 changed files with 38 additions and 21 deletions

View File

@ -30,7 +30,7 @@ struct FFFInputState
GENERATED_BODY()
FVector2D MoveAxes;
FVector2D LookAxes;
FRotator LookRot;
UPROPERTY(EditAnywhere, Meta = (Bitmask))
int32 Buttons;
@ -38,7 +38,7 @@ struct FFFInputState
FFFInputState()
: MoveAxes(FVector2D::ZeroVector)
, LookAxes(FVector2D::ZeroVector)
, LookRot(FRotator::ZeroRotator)
, Buttons(0)
, DisabledButtons(0)
{

View File

@ -7,6 +7,7 @@
// UE includes
#include "EnhancedInputSubsystems.h"
#include "Kismet/KismetMathLibrary.h"
AFFPlayerController::AFFPlayerController()
{
@ -25,6 +26,29 @@ void AFFPlayerController::ModifyRawInput()
}
bool AFFPlayerController::HasMoveInput()
{
// TODO: configurable deadzone
return !ModifiedInput.MoveAxes.IsNearlyZero();
}
void AFFPlayerController::ConsumeMoveInput()
{
RawInput.MoveAxes = FVector2D::ZeroVector;
}
FVector AFFPlayerController::GetInputAsWorldDirection() const
{
FRotator ViewRotationYaw = FRotator(0.0f, ModifiedInput.LookRot.Yaw, 0.0f);
FVector ForwardInput = UKismetMathLibrary::GetForwardVector(ViewRotationYaw) * ModifiedInput.MoveAxes.Y;
FVector RightInput = UKismetMathLibrary::GetRightVector(ViewRotationYaw) * ModifiedInput.MoveAxes.X;
return ForwardInput + RightInput;
}
void AFFPlayerController::FixedTick(float OneFrame)
{
//UnacknowledgedInputs.Push(RawInput);

View File

@ -36,7 +36,7 @@ public:
* @brief Gets the current input after cleaning/modifying the raw input state
* @return the current input
*/
virtual FFFInputState GetModifiedInput() const { return ModifiedInput; };
virtual FFFInputState GetModifiedInput() const { return ModifiedInput; }
/**
* @brief Function called before inputs are passed to the game logic to update the game state.
@ -47,6 +47,17 @@ public:
*/
virtual void ModifyRawInput();
/**
* @brief Checks if the current input state has movement input being applied
* @return True if move axes is non-zero, false otherwise
*/
UFUNCTION(BlueprintPure)
bool HasMoveInput();
void ConsumeMoveInput();
FVector GetInputAsWorldDirection() const;
// IFFSystemInterface interface
virtual void FixedTick(float OneFrame) override;
// End of IFFSystemInterface

View File

@ -71,8 +71,6 @@ void UFFState::Enter(const FFFStateContext& InStateContext)
void UFFState::Exit(const FFFStateContext& InStateContext, EFFStateFinishReason StateFinishReason)
{
if(InStateContext.Avatar &&
(bStopMontageOnStateEnd && StateFinishReason == EFFStateFinishReason::SFT_DurationMetOrExceeded || StateFinishReason == EFFStateFinishReason::SFT_Interrupted) ||
(bStopMontageOnMovementModeChange && StateFinishReason == EFFStateFinishReason::SFT_NotInReqMovementMode))
@ -133,16 +131,6 @@ void UFFState::MovementModeChanged(EMovementMode PrevMovementMode, uint8 Previou
{
OnMovementModeChanged(PrevMovementMode, PreviousCustomMode,
NewMovementMode, NewCustomMode, InStateContext);
// TODO: Movement mode MOVE_None means movement is disabled but in this context it means no movement
// mode is specifically required to stay in this state i.e. changing from falling to walking
// will not exit out of this state. I think I want to use my own movement mode enum just so I
// can explicitly document this is what is meant by none
if((ReqMovementMode != EMovementMode::MOVE_None && NewMovementMode != ReqMovementMode) ||
((ReqMovementMode == MOVE_Custom) && NewCustomMode != RequiredCustomMode))
{
Finish(InStateContext, EFFStateFinishReason::SFT_NotInReqMovementMode);
}
}

View File

@ -119,12 +119,6 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties")
bool bCanTransitionToSelf = false;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties")
TEnumAsByte<EMovementMode> ReqMovementMode;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties")
uint8 RequiredCustomMode;
/**
* Animation to begin playing when this state is entered
*/