diff --git a/Source/UnrealFightingFramework/Input/FFInputBufferComponent.h b/Source/UnrealFightingFramework/Input/FFInputBufferComponent.h index 698e603..be9d3c3 100644 --- a/Source/UnrealFightingFramework/Input/FFInputBufferComponent.h +++ b/Source/UnrealFightingFramework/Input/FFInputBufferComponent.h @@ -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) { diff --git a/Source/UnrealFightingFramework/Input/FFPlayerController.cpp b/Source/UnrealFightingFramework/Input/FFPlayerController.cpp index c8fea47..b3a52c8 100644 --- a/Source/UnrealFightingFramework/Input/FFPlayerController.cpp +++ b/Source/UnrealFightingFramework/Input/FFPlayerController.cpp @@ -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); diff --git a/Source/UnrealFightingFramework/Input/FFPlayerController.h b/Source/UnrealFightingFramework/Input/FFPlayerController.h index e1fcc05..8df7814 100644 --- a/Source/UnrealFightingFramework/Input/FFPlayerController.h +++ b/Source/UnrealFightingFramework/Input/FFPlayerController.h @@ -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 diff --git a/Source/UnrealFightingFramework/State/FFState.cpp b/Source/UnrealFightingFramework/State/FFState.cpp index 2693143..97a196f 100644 --- a/Source/UnrealFightingFramework/State/FFState.cpp +++ b/Source/UnrealFightingFramework/State/FFState.cpp @@ -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); - } } diff --git a/Source/UnrealFightingFramework/State/FFState.h b/Source/UnrealFightingFramework/State/FFState.h index 8a80d93..bee5756 100644 --- a/Source/UnrealFightingFramework/State/FFState.h +++ b/Source/UnrealFightingFramework/State/FFState.h @@ -119,12 +119,6 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties") bool bCanTransitionToSelf = false; - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties") - TEnumAsByte ReqMovementMode; - - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties") - uint8 RequiredCustomMode; - /** * Animation to begin playing when this state is entered */