Collect move axis and look rot input
This commit is contained in:
parent
d53fba996a
commit
b62a8cebb6
@ -30,7 +30,7 @@ struct FFFInputState
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
FVector2D MoveAxes;
|
FVector2D MoveAxes;
|
||||||
FVector2D LookAxes;
|
FRotator LookRot;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Meta = (Bitmask))
|
UPROPERTY(EditAnywhere, Meta = (Bitmask))
|
||||||
int32 Buttons;
|
int32 Buttons;
|
||||||
@ -38,7 +38,7 @@ struct FFFInputState
|
|||||||
|
|
||||||
FFFInputState()
|
FFFInputState()
|
||||||
: MoveAxes(FVector2D::ZeroVector)
|
: MoveAxes(FVector2D::ZeroVector)
|
||||||
, LookAxes(FVector2D::ZeroVector)
|
, LookRot(FRotator::ZeroRotator)
|
||||||
, Buttons(0)
|
, Buttons(0)
|
||||||
, DisabledButtons(0)
|
, DisabledButtons(0)
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
// UE includes
|
// UE includes
|
||||||
#include "EnhancedInputSubsystems.h"
|
#include "EnhancedInputSubsystems.h"
|
||||||
|
#include "Kismet/KismetMathLibrary.h"
|
||||||
|
|
||||||
AFFPlayerController::AFFPlayerController()
|
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)
|
void AFFPlayerController::FixedTick(float OneFrame)
|
||||||
{
|
{
|
||||||
//UnacknowledgedInputs.Push(RawInput);
|
//UnacknowledgedInputs.Push(RawInput);
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
* @brief Gets the current input after cleaning/modifying the raw input state
|
* @brief Gets the current input after cleaning/modifying the raw input state
|
||||||
* @return the current input
|
* @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.
|
* @brief Function called before inputs are passed to the game logic to update the game state.
|
||||||
@ -47,6 +47,17 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void ModifyRawInput();
|
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
|
// IFFSystemInterface interface
|
||||||
virtual void FixedTick(float OneFrame) override;
|
virtual void FixedTick(float OneFrame) override;
|
||||||
// End of IFFSystemInterface
|
// End of IFFSystemInterface
|
||||||
|
@ -71,8 +71,6 @@ void UFFState::Enter(const FFFStateContext& InStateContext)
|
|||||||
|
|
||||||
void UFFState::Exit(const FFFStateContext& InStateContext, EFFStateFinishReason StateFinishReason)
|
void UFFState::Exit(const FFFStateContext& InStateContext, EFFStateFinishReason StateFinishReason)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if(InStateContext.Avatar &&
|
if(InStateContext.Avatar &&
|
||||||
(bStopMontageOnStateEnd && StateFinishReason == EFFStateFinishReason::SFT_DurationMetOrExceeded || StateFinishReason == EFFStateFinishReason::SFT_Interrupted) ||
|
(bStopMontageOnStateEnd && StateFinishReason == EFFStateFinishReason::SFT_DurationMetOrExceeded || StateFinishReason == EFFStateFinishReason::SFT_Interrupted) ||
|
||||||
(bStopMontageOnMovementModeChange && StateFinishReason == EFFStateFinishReason::SFT_NotInReqMovementMode))
|
(bStopMontageOnMovementModeChange && StateFinishReason == EFFStateFinishReason::SFT_NotInReqMovementMode))
|
||||||
@ -133,16 +131,6 @@ void UFFState::MovementModeChanged(EMovementMode PrevMovementMode, uint8 Previou
|
|||||||
{
|
{
|
||||||
OnMovementModeChanged(PrevMovementMode, PreviousCustomMode,
|
OnMovementModeChanged(PrevMovementMode, PreviousCustomMode,
|
||||||
NewMovementMode, NewCustomMode, InStateContext);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,12 +119,6 @@ public:
|
|||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties")
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties")
|
||||||
bool bCanTransitionToSelf = false;
|
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
|
* Animation to begin playing when this state is entered
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user