TheRedPixel

C++ Motion Matching

Sep 11th, 2025 (edited)
1,061
0
Never
9
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 81.95 KB | Gaming | 0 0
  1. [HEADER]
  2.  
  3. #pragma once
  4.  
  5. #include "CoreMinimal.h"
  6. #include "Animation/AnimInstanceProxy.h"
  7. #include "Animation/SDAnimInstance.h"
  8. #include "Chooser.h"
  9. #include "SDTypes.h"
  10. #include "AbilitySystem/Abilities/SDGA_WallRun.h"
  11. #include "Animation/AnimNodeReference.h"
  12. #include "BoneControllers/AnimNode_FootPlacement.h"
  13. #include "PoseSearch/PoseSearchTrajectoryLibrary.h"
  14. #include "PoseSearch/PoseSearchDatabase.h"
  15. #include "PoseSearch/PoseSearchTrajectoryTypes.h"
  16. #include "BoneControllers/AnimNode_OffsetRootBone.h"
  17. #include "PoseSearch/PoseSearchInteractionLibrary.h"
  18. #include "BoneControllers/AnimNode_OrientationWarping.h"
  19. #include "Character/SDCharacterMovementComponent.h"
  20. #include "Abilities/Async/AbilityAsync_WaitGameplayTag.h"
  21. #include "MotionCapture/InterfacePoseSearch.h"
  22. #include "SDKenyaAnimInstance.generated.h"
  23.  
  24. class UPoseSearchDatabase;
  25. class UAbilityAsync_WaitGameplayEvent;
  26. class UCharacterMovementComponent;
  27. class ASDKenyaCharacter;
  28. struct FAnimNodeReference;
  29. struct FAnimUpdateContext;
  30. /**
  31.  *
  32.  */
  33. USTRUCT()
  34. struct FTPAnimInstanceProxy : public FAnimInstanceProxy
  35. {
  36.     GENERATED_BODY()
  37.  
  38. protected:
  39.     virtual void InitializeObjects(UAnimInstance* InAnimInstance) override;
  40.     virtual void PreUpdate(UAnimInstance* InAnimInstance, float DeltaSeconds) override;
  41.     virtual void Update(float DeltaSeconds) override;
  42.  
  43. public:
  44.     FPoseSearchQueryTrajectory OutTrajectory;
  45.     FPoseSearchQueryTrajectorySample OutTrajectorySample1;
  46.     FPoseSearchQueryTrajectorySample OutTrajectorySample2;
  47.  
  48.     TWeakObjectPtr<ASDKenyaCharacter> Character;
  49.     TWeakObjectPtr<USDCharacterMovementComponent> CharacterMovement;
  50. };
  51. /**
  52.  *
  53.  */
  54. UCLASS()
  55. class USDKenyaAnimInstance :  public USDAnimInstance, public IInterfacePoseSearch
  56. {
  57.     GENERATED_BODY()
  58.  
  59. public:
  60.     //Assets
  61.     UPROPERTY(EditDefaultsOnly)
  62.     TObjectPtr<UAnimMontage> LandRollMontage;
  63.  
  64.     //Utility
  65.     bool bHasRun = false;
  66.     FORCEINLINE bool CanRunOnce()
  67.     {
  68.         if (!bHasRun){
  69.             bHasRun = true;
  70.             return true; // First time  can run
  71.         }
  72.         return false;
  73.     }
  74.    
  75.     //Functions fixes for AnimGraph Fast Path
  76.     UPROPERTY(BlueprintReadOnly)
  77.     bool bIsAirDashOrIsDoubleAirDash;
  78.     FORCEINLINE void GetIsAirDashOrIsDoubleAirDash() {bIsAirDashOrIsDoubleAirDash =  bIsDoubleAirDash || bIsAirDash; }
  79.     UPROPERTY(BlueprintReadOnly)
  80.     float SlidingDownFalseBlendValue;
  81.     /*FORCEINLINE void GetSlidingDownFalseBlendValue() {SlidingDownFalseBlendValue = Montage_IsActive(SlidingDownMontage) ? 0.1f : 1.5f;}
  82.  
  83.     UPROPERTY(EditDefaultsOnly)
  84.     TObjectPtr<UAnimMontage> SlidingDownMontage;*/
  85.    
  86. protected:
  87.     //Multi Threaded Proxy Logic
  88.     UPROPERTY(Transient)
  89.     FTPAnimInstanceProxy Proxy;
  90.     virtual FTPAnimInstanceProxy* CreateAnimInstanceProxy() override {return &Proxy;}
  91.     virtual void DestroyAnimInstanceProxy(FAnimInstanceProxy* InProxy) override {};
  92.     virtual void NativeThreadSafeUpdateAnimation(float DeltaSeconds) override;
  93.    
  94.     virtual void NativeInitializeAnimation() override;
  95.     virtual void NativeUpdateAnimation(float DeltaSeconds) override;
  96.  
  97. /**/
  98.     UPROPERTY(Transient, BlueprintReadOnly)
  99.     ASDKenyaCharacter* Character;
  100.     UPROPERTY(Transient, BlueprintReadOnly)
  101.     UCharacterMovementComponent* CharacterMovement;
  102.     UPROPERTY()
  103.     TArray<TObjectPtr<AActor>> EmptyArray;
  104.  
  105.     void GenerateTrajectory(const float DeltaSeconds);
  106.     void UpdateEssentialValue(const float DeltaSeconds);
  107.     void UpdateWallRunValues(const float DeltaSeconds);
  108.     void UpdateFreeClimbValues(const float DeltaSeconds);
  109.     void UpdateSlideValues(const float DeltaSeconds);
  110.     void UpdatePullPushValues(const float DeltaSeconds);
  111.     void UpdateBeamWalkValues(const float DeltaSeconds);
  112.     void UpdateStates();
  113.     void SetMotionMatchingDB();//Works for ST
  114.  
  115.     /// mocap data update , interface
  116.     virtual FTransform GetInteractionTransform() const override;
  117.     virtual void SetInteractionTransform(FTransform SetTransform)  override;
  118.  
  119.     UPROPERTY(BlueprintReadWrite)
  120.     FAnimNodeReference UpdateRootBoneNode;
  121.  
  122.     /*UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Anim Nodes", meta=(PinShownByDefault))
  123.     FAnimNode_OffsetRootBone OffsetRootNode;*/
  124.    
  125.     UPROPERTY(BlueprintReadWrite, Category = "Movement")
  126.     FVector FutureVelocity;
  127.     UPROPERTY(BlueprintReadOnly, Category = "Movement")
  128.     FVector VelocityLastFrame;
  129.    
  130.     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Pose Search")
  131.     FPoseSearchTrajectoryData TrajectoryGenerationData_Idle;
  132.     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Pose Search")
  133.     FPoseSearchTrajectoryData TrajectoryGenerationData_Moving;
  134.  
  135.     UPROPERTY(BlueprintReadWrite, Category = "Pose Search")
  136.     FPoseSearchQueryTrajectory Trajectory;
  137.     UPROPERTY(BlueprintReadWrite, Category = "Movement")
  138.     FPoseSearchTrajectory_WorldCollisionResults TrajectoryCollision;
  139.     UPROPERTY(BlueprintReadWrite) // Read only
  140.     double Speed2D;
  141.     float PreviousDesiredControllerYaw;
  142.     UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
  143.     FTransform CharacterTransform;
  144.     UPROPERTY(BlueprintReadWrite, Category = "Movement") // NO
  145.     bool bOffsetRootBoneEnabled;
  146.     UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
  147.     FTransform RootTransform;
  148.     UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
  149.     FVector Acceleration;
  150.  
  151.     UPROPERTY(BlueprintReadWrite, Category = "Movement")
  152.     bool bIsOnGround;
  153.  
  154.     #pragma region WallRunVariables
  155.     UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
  156.     bool bIsWallRunning = false;
  157.     UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
  158.     bool bIsWallJumping = false;
  159.     UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
  160.     bool bIsWallRunningORJumping = false;
  161.     UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
  162.     bool bIsWallRunningNORJumping = false;
  163.  
  164.     UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
  165.     EWallRunDirection WallSide = EWallRunDirection::Right;
  166.     UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
  167.     bool bIsWallSideRight = true;
  168.     UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
  169.     bool bIsWallSideLeft = false;
  170.  
  171.     UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
  172.     float CurrentArcAngle = 0.f;
  173.     UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
  174.     float CurrentTurnRate = 0.f;
  175.  
  176.     UPROPERTY(BlueprintReadOnly, Category = "Wall Jump", meta = (ToolTip = "The horizontal velocity at which the character will be launched from the wall when wall-jumping."))
  177.     float WallJumpHorizontalVelocity = 800.f;
  178.     UPROPERTY(BlueprintReadOnly, Category = "Wall Jump", meta = (ToolTip = "The vertical velocity at which the character will be launched from the wall when wall-jumping."))
  179.     float WallJumpVerticalVelocity = 500.f;
  180.  
  181.     UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
  182.     float CurrentSpeed = 0.f;
  183.  
  184.     UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
  185.     float WallRunAnimPlayRate = 0.f;
  186.    
  187.     UPROPERTY(BlueprintReadOnly, Category = "Wall Jump")
  188.     float WallJumpAnimationSpeed = 0.f;
  189.  
  190.     UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
  191.     float HandCorrectionAdditive = 0.f;
  192.     #pragma endregion
  193.    
  194. //3rd Batch
  195.     UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
  196.     bool bHasAcceleration;
  197.     UPROPERTY(BlueprintReadWrite, Category = "Movement")
  198.     FVector Velocity_LastFrame;// Read only
  199.     UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
  200.     FVector Velocity;
  201.  
  202.     UPROPERTY(BlueprintReadWrite, Category = "Movement")  // Read only
  203.     bool bHasVelocity;
  204.  
  205.     UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
  206.     FVector VelocityAcceleration;
  207.  
  208.     UPROPERTY(BlueprintReadWrite, Category = "Movement")
  209.     FVector LastNonZeroVelocity;
  210.  
  211.     UPROPERTY(BlueprintReadWrite, Category = "CrowdAvoidance")  // Read only
  212.     double AwarenessSpineRotation;
  213.     UPROPERTY(BlueprintReadOnly, Category = "CrowdAvoidance")  
  214.     double AwarenessSpineRotationNegative;
  215.    
  216.     UPROPERTY(BlueprintReadWrite, Category = "CrowdAvoidance")  // Read only
  217.     double AwarenessSpineRotator;
  218.  
  219.     /*UPROPERTY(BlueprintReadOnly) REPLACED BY DIRECT NODE Ref
  220.     FTransform AnimNodeOffsetRootTransform; */
  221.  
  222.     // Zipline
  223.     UPROPERTY(BlueprintReadWrite, Category = "Movement")
  224.     bool bIsZiplining;
  225.  
  226.    
  227. public:
  228.    
  229.     UPROPERTY(BlueprintReadWrite, Category = "Movement")  // Read only
  230.     float AccelerationAmount;
  231.     UPROPERTY(BlueprintReadOnly)
  232.     bool bIsQTEDrone;
  233.  
  234.     UPROPERTY(BlueprintReadOnly)
  235.     bool bDeathFromAbove;
  236.  
  237.     UPROPERTY(BlueprintReadOnly)
  238.     bool bQTEDroneSuccess;
  239.  
  240.     UPROPERTY(BlueprintReadOnly)
  241.     bool bQTEDroneFailure;
  242.  
  243.     //Brawler Death From Above
  244.     UPROPERTY(BlueprintReadOnly)
  245.     bool bDeathFromAboveNPC;
  246.  
  247.     UPROPERTY(BlueprintReadOnly)
  248.     bool bDeathFromAboveNPCLoopStart;
  249.  
  250.     UPROPERTY(BlueprintReadOnly)
  251.     bool bDeathFromAboveNPCPunchStart;
  252.  
  253.     UPROPERTY(BlueprintReadOnly)
  254.     bool bDeathFromAboveNPCBackFlipStart;
  255.    
  256.     UPROPERTY(BlueprintReadOnly, Category = "Takedown")
  257.     float TakeDownNPCLoopAnimSpeed;
  258.  
  259.     UPROPERTY(BlueprintReadOnly)
  260.     bool bAllowImmediateRotation;
  261.  
  262.     TArray<FName> CurrentDatabaseTags;
  263.  
  264.     UPROPERTY(BlueprintReadOnly)
  265.     int32 MMDatabaseLOD;
  266.  
  267.     UPROPERTY(EditDefaultsOnly, Category = "Motion Matching | CHT")
  268.     TObjectPtr<const UChooserTable> MainCHT;
  269.  
  270.     UPROPERTY(EditDefaultsOnly, Category = "Motion Matching | CHT")
  271.     TObjectPtr<const UChooserTable> CombatCHT;
  272.    
  273.     UPROPERTY(EditDefaultsOnly, Category = "Motion Matching | CHT")
  274.     TObjectPtr<const UChooserTable> MiniGunCHT;
  275.  
  276.     UPROPERTY(EditDefaultsOnly, Category = "Motion Matching | CHT")
  277.     TObjectPtr<const UChooserTable> PsycheCHT;
  278.  
  279.     UPROPERTY(EditDefaultsOnly, Category = "Motion Matching | CHT")//none
  280.     const UChooserTable* CurrentCHT = MainCHT;
  281.    
  282.     UPROPERTY(Transient,EditDefaultsOnly, BlueprintReadOnly, Category = "Pose Search")
  283.     TWeakObjectPtr<const UPoseSearchDatabase> CurrentSelectedDatabase;
  284.    
  285.     // Movement Mode
  286.     UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
  287.     EMM_MovementMode MovementMode = EMM_MovementMode::OnGround;
  288.  
  289.     UPROPERTY(BlueprintReadWrite, Category = "Movement")// Read only
  290.     EMM_MovementMode MovementMode_LastFrame = EMM_MovementMode::OnGround;
  291.    
  292.     UPROPERTY( BlueprintReadWrite, Category = "Movement") // Read only
  293.     EMM_RotationMode RotationMode = EMM_RotationMode::OrientToMovement;
  294.  
  295.     UPROPERTY( BlueprintReadWrite, Category = "Movement") // Read only
  296.     EMM_RotationMode RotationMode_LastFrame = EMM_RotationMode::OrientToMovement;
  297.  
  298.     UPROPERTY( BlueprintReadWrite, Category = "Movement") // Read only
  299.     EMM_MovementState MovementState_LastFrame = EMM_MovementState::Idle;
  300.  
  301.     UPROPERTY( BlueprintReadWrite, Category = "Movement") // Read only
  302.     EMM_MovementState MovementState = EMM_MovementState::Idle;
  303.  
  304.     UPROPERTY( BlueprintReadWrite, Category = "Movement")// Read only
  305.     EMM_Gait Gait_LastFrame = EMM_Gait::Walk;
  306.     UPROPERTY( BlueprintReadWrite, Category = "Movement")// Read only
  307.     EMM_Gait Gait = EMM_Gait::Walk;
  308.     UPROPERTY( BlueprintReadWrite, Category = "Movement")// Read only
  309.     EMM_Gait PreviousGroundedGait = EMM_Gait::Walk;
  310.    
  311.     UPROPERTY( BlueprintReadWrite, Category = "Movement")// Read only
  312.     EMM_Stance Stance_LastFrame = EMM_Stance::Stand;
  313.  
  314.     UPROPERTY( BlueprintReadWrite, Category = "Movement")// Read only
  315.     EMM_Stance Stance = EMM_Stance::Stand;
  316.  
  317.     UPROPERTY( BlueprintReadWrite, Category = "Overlay")
  318.     EOverlayState OverlayState = EOverlayState::Unarmed;
  319.  
  320.     UPROPERTY(  BlueprintReadWrite, Category = "Overlay")
  321.     EOverlayState PreviousOverlayState = EOverlayState::Unarmed;
  322.  
  323.     UPROPERTY( BlueprintReadWrite, Category = "Climbing")
  324.     EClimbState ClimbState = EClimbState::Default;
  325.  
  326.     UPROPERTY( BlueprintReadWrite, Category = "Climbing")
  327.     EReachDirection ReachDirection = EReachDirection::Up;
  328.  
  329.     UPROPERTY( BlueprintReadOnly, Category = "Climbing")
  330.     EClimbTransition ClimbTransition = EClimbTransition::Shimmy;
  331.  
  332.     // Motion Matching
  333.     UPROPERTY( BlueprintReadWrite, Category = "Motion Matching") // ReadOnly
  334.     E_KenyaMotionMatchingDB MotionMatchingDB_LastFrame = E_KenyaMotionMatchingDB::Normal;
  335.  
  336.     UPROPERTY( BlueprintReadWrite, Category = "Motion Matching") // ReadOnly
  337.     E_KenyaMotionMatchingDB MotionMatchingDB = E_KenyaMotionMatchingDB::Normal;
  338.  
  339.     UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Motion Matching")
  340.     bool bChangeMotionMatchingDBGet_MMInterruptNow=false;
  341.  
  342.     UFUNCTION(BlueprintCallable, Category = "Motion Matching")
  343.     void ChangeMMInterruptToTrue(); //To force to change MMInterrupt to true for a while
  344.  
  345.     FTimerHandle TimerHandleInterruptToTrue;
  346.     UFUNCTION()
  347.     void ChangeMMInterruptToTrueNow();
  348.  
  349.    
  350.     UPROPERTY(BlueprintReadOnly, Category = "Movement")
  351.     bool bIsADS;//
  352.  
  353.     UPROPERTY(BlueprintReadOnly, Category = "Movement")
  354.     bool bIsTurningInPlace;
  355.  
  356.  
  357.  
  358.     UFUNCTION(BlueprintCallable)
  359.     FORCEINLINE void IsTurningInPlaceUpdate(){bIsTurningInPlace = CurrentDatabaseTags.Contains("TurnInPlace");}
  360.  
  361.     //  cover system
  362.     UPROPERTY(BlueprintReadWrite, Category = "Cover")
  363.     bool bInCover=false;
  364.     UPROPERTY(BlueprintReadWrite, Category = "Cover")
  365.     bool bIsCoverPivotRight=false;
  366.     UPROPERTY(BlueprintReadWrite, Category = "Cover")
  367.     bool bIsCoverPivoting=false;
  368.     UPROPERTY(BlueprintReadWrite, Category = "Cover")
  369.     bool bInCoverPeeking=false;
  370.     UPROPERTY(BlueprintReadWrite, Category = "Cover")
  371.     bool bIsVaultingCover=false;
  372.     UPROPERTY(BlueprintReadWrite, Category = "Cover")
  373.     bool bIsCoverRight=true;
  374.     UPROPERTY(BlueprintReadWrite, Category = "Cover")
  375.     bool bExitingCover=false;
  376.     UPROPERTY(BlueprintReadWrite, Category = "Cover")
  377.     bool bSkipTransition=false;
  378.     UPROPERTY(BlueprintReadWrite, Category = "Cover")
  379.     bool bIsMovingNow=false;
  380.     UPROPERTY(BlueprintReadWrite, Category = "Cover")
  381.     bool bInCombat=false;
  382.     UPROPERTY(BlueprintReadWrite, Category = "Cover")
  383.     bool bCoverEnteredFully;
  384.  
  385.     UFUNCTION(BlueprintCallable)
  386.     void CoversystemMovingCheckUpdate();
  387.  
  388.     // Timer handle declaration
  389.     FTimerHandle TimerHandleCoverStart;
  390.  
  391.     //Cover moving check start timer
  392.     UFUNCTION(BlueprintCallable)
  393.     void StartTimerCover();
  394.  
  395.     //Cover moving check stop timer
  396.     UFUNCTION(BlueprintCallable)
  397.     void StopTimerCover();
  398.    
  399.  
  400.     //  shockfire AimOffset system
  401.     UPROPERTY(BlueprintReadWrite, Category = "Shockfire")
  402.     float ShockPitch;
  403.     UPROPERTY(BlueprintReadWrite, Category = "Shockfire")
  404.     float ShockYaw;
  405.  
  406.     // Idle Aim offset
  407.     UPROPERTY(BlueprintReadWrite, Category = "AimOffset")
  408.     bool UseIdleAimOffset=true;
  409.     UPROPERTY(BlueprintReadWrite, Category = "AimOffset")
  410.     float IdleAimOffsetYaw;
  411.     UPROPERTY(BlueprintReadWrite, Category = "AimOffset")
  412.     float IdleAimOffsetPitch;
  413.  
  414.  
  415.    
  416.     void IdleAimOffsetYawPitchUpdate(float DeltaTime); 
  417.    
  418.    
  419.  
  420.     //Cover moving check stop timer
  421.     UFUNCTION(BlueprintCallable)
  422.     void ShockFirePawPitchUpdate();
  423.  
  424.     // Timer handle
  425.     FTimerHandle TimerHandleShockAOScan;
  426.     //Cover moving check stop timer
  427.     UFUNCTION(BlueprintCallable)
  428.     void ShockFireAOchangeStateScanBack();
  429.  
  430.     FTimerHandle TimerHandleStateShockFireAimOfsett;
  431.  
  432.     UFUNCTION(BlueprintCallable)
  433.     void SetStateShockFireAimOfsett(bool start);
  434.  
  435.     ///
  436.     UPROPERTY(BlueprintReadWrite, Category = "Shockfire")
  437.     bool ShockFireUseRightHand=false;
  438.     UPROPERTY(BlueprintReadWrite, Category = "Shockfire")
  439.     bool bUseShockFire = false;
  440.     // psycheScan normal
  441.     UPROPERTY(BlueprintReadWrite, Category = "Shockfire")
  442.     bool psycheScanNoUseRightHandNow=false;
  443.  
  444.     //idleTurnInplace
  445.     UPROPERTY(BlueprintReadWrite, Category = "psycheScan")
  446.     bool idleTurnInplace = false;
  447.     void idleTurnInplaceTick();
  448.  
  449.  
  450.     //minigun
  451.     UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Minigun")
  452.     bool bMinigunActive;
  453.     UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Minigun")
  454.     float pitchMinigun;
  455.  
  456.     FTimerHandle MyTimerHandle;
  457.  
  458.     UFUNCTION(BlueprintCallable)
  459.     void StartMinigunShooting(bool startShootingAimOffset);
  460.  
  461.  
  462.    
  463.  
  464.    
  465.     UFUNCTION()
  466.     void PlayerPitchUpdate();
  467.  
  468.     // PsycheScan Aim + Turn inplace
  469.     UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="PsycheScan")
  470.     bool bUsePsycheScanTurnInplaceSystem;
  471.  
  472.     float TurnYawCurveValue;
  473.     UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="PsycheScan")
  474.     float RootYawOffset1;
  475.    
  476.     float YawDeltaSinceLastUpdate2;
  477.     UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="PsycheScan")
  478.     float TurnInPlaceAnimTime;
  479.    
  480.     float TurninPlaceRotationDirection;
  481.     UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="PsycheScan")
  482.     FVector2D RootYawOffsetAngleClamp = FVector2D(-80.0f,80.0f);
  483.     FRotator WorldRotation;
  484.    
  485.     UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="PsycheScan")
  486.     UAnimSequence* TurninPlaceRight;
  487.    
  488.     UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="PsycheScan")
  489.     UAnimSequence* TurninPlaceLeft;
  490.     bool IsFirstUpdate=true;
  491.     float PreviousTurnYawCurveValue;
  492.     UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
  493.     void SetRootYawOffset1(float InRootYawOffset);
  494.     UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
  495.     void ProcessTurnYawCurve();
  496.     UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
  497.     void UpdateRootYawOffset(float InDeltaTime);
  498.     UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
  499.     void UpdateIdleState(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
  500.     UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
  501.     void UpdateRotationData();
  502.     UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
  503.     void SetupTurnInPlaceAnim(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
  504.     UAnimSequence* SelectTurnInPlaceAnimation(float Direction);
  505.     UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
  506.     void UpdateTurnInPlaceAnim(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
  507.     UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
  508.     void SetUpTurnInPlaceRotationState(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
  509.     //void SetUpTurnInPlaceRecoveryState(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
  510.     UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
  511.     void UpdateTurnInPlaceRecoveryAnim(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
  512.     //void ResetIdleBreakTransitionLogic();
  513.     //void ChooseIdleBreakDelayTime();
  514.     //void GetMainAnimBPThreadSafe();
  515.     //void SetUpIdleState();
  516.     //void GetMainAnimBPThreadSafe_0();
  517.     //void CheckToRestartANim();
  518.     UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
  519.     void OnStateEntry(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
  520.     UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
  521.     void OnStateFullyBlendedIn_0(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
  522.     //void OnStateFullyBlendedOut(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
  523.  
  524.  
  525.  
  526.    
  527.    
  528.     // Additional Transform Variables
  529.     UPROPERTY(BlueprintReadOnly, Category = "Character")
  530.     FTransform LeftStepStartTransform;
  531.     UPROPERTY(BlueprintReadOnly, Category = "Turn In Place")
  532.     FTransform RightStepStartTransform;
  533.  
  534.     UPROPERTY(BlueprintReadOnly, Category = "Turn In Place")
  535.     FTransform TurnInPlace_LeftFootTransform;
  536.  
  537.     UPROPERTY(BlueprintReadOnly, Category = "Turn In Place")
  538.     FTransform TurnInPlace_RightFootTransform;
  539.  
  540.     // Float and Boolean Variables
  541.     UPROPERTY(BlueprintReadOnly, Category = "Footstep")
  542.     double LeftFootstepDuration;//
  543.  
  544.     UPROPERTY(BlueprintReadOnly, Category = "Footstep")
  545.     double RightFootstepDuration;//
  546.  
  547.     UPROPERTY(BlueprintReadOnly, Category = "Footstep")
  548.     bool bMoveLeftFoot;//
  549.  
  550.     UPROPERTY(BlueprintReadOnly, Category = "Footstep")
  551.     bool bMoveRightFoot;//
  552.  
  553.     // Rotation and Movement
  554.     UPROPERTY(BlueprintReadOnly, Category = "Movement")
  555.     double TurnInPlaceDuration;//
  556.  
  557.     UPROPERTY(BlueprintReadOnly, Category = "Movement")
  558.     bool bIsOrientingToMovement; //
  559.  
  560.     UPROPERTY(BlueprintReadOnly, Category = "Movement")
  561.     bool bIsUsingDesiredRotation; //
  562.  
  563.     // Miscellaneous
  564.     UPROPERTY(BlueprintReadOnly, Category = "Weapon")
  565.     FTransform MinigunTransform;
  566.  
  567.     UPROPERTY(BlueprintReadOnly, Category = "Combat")
  568.     bool bAiming;//
  569.  
  570.     UPROPERTY(BlueprintReadOnly, Category = "Combat")
  571.     FTransform ProjectileLeftHandPlacement;
  572.    
  573.     // Landing and Jumping
  574.     UPROPERTY(BlueprintReadOnly, Category = "Landing")
  575.     bool bLocomotionLanded;//
  576.  
  577.     UPROPERTY(BlueprintReadOnly, Category = "Landing")
  578.     FVector LandVelocity;
  579.  
  580.     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Landing")
  581.     double HeavyLandSpeedThreshold = 1125;//
  582.  
  583.     UPROPERTY(BlueprintReadOnly, Category = "Landing")
  584.     TArray<FName> FloorActorTags;
  585.    
  586.     UPROPERTY(BlueprintReadOnly, Category = "Jumping")
  587.     bool bIsDoubleJump;//
  588.  
  589.     UPROPERTY(BlueprintReadOnly, Category = "Jumping")
  590.     bool bLandFromDoubleJump;//
  591.  
  592.     UPROPERTY(BlueprintReadOnly, Category = "Jumping")
  593.     bool bIsDoubleJumpStart;//
  594.    
  595.     // Air Dash
  596.     UPROPERTY(BlueprintReadOnly, Category = "Movement")
  597.     bool bIsAirDash;//
  598.  
  599.     UPROPERTY(BlueprintReadOnly, Category = "Movement")
  600.     bool bIsDoubleAirDash;//
  601.  
  602.     UPROPERTY(BlueprintReadOnly, Category = "Movement")
  603.     bool bLandFromAirDash;//
  604.  
  605.     // Climbing
  606.     UPROPERTY(BlueprintReadWrite, Category = "Climbing")
  607.     bool bIsClimbing;//
  608.  
  609.     UPROPERTY(BlueprintReadWrite, Category = "Climbing")
  610.     bool bIsClimbReaching;//
  611.    
  612.     UPROPERTY(BlueprintReadWrite, Category = "Climbing")
  613.     bool bIsClimbReachingValid;//
  614.  
  615.     UPROPERTY(BlueprintReadOnly, Category = "Climbing")
  616.     bool bIsReachChangingDirection;//
  617.  
  618.     UPROPERTY(BlueprintReadWrite, Category = "Climbing")
  619.     bool bStandShimmyRight; //
  620.  
  621.     UPROPERTY(BlueprintReadWrite, Category = "Input")
  622.     FVector2D CachedInputVector;
  623.  
  624.     UPROPERTY(BlueprintReadOnly, Category = "Input")
  625.     bool bIsClimbTransitioning;//
  626.  
  627.     UPROPERTY(BlueprintReadWrite, Category = "Input")
  628.     FVector2D InputRawMovementSpeed;
  629.    
  630.     UPROPERTY(BlueprintReadWrite, Category = "Input")
  631.     FVector2D InputMovementSpeed;
  632.  
  633.     UPROPERTY(BlueprintReadOnly, Category = "Input")
  634.     bool bIsPerchTurnEnded;//
  635.  
  636.     UPROPERTY(BlueprintReadWrite, Category = "Input")// Read only
  637.     FVector InputVector;
  638.  
  639.     // Climb and Pipe Climb
  640.     UPROPERTY(BlueprintReadWrite, Category = "Climbing")
  641.     bool bPipeClimbRight;//
  642.  
  643.     UPROPERTY(BlueprintReadWrite, Category = "Climbing") // Read only
  644.     FVector RightVector;
  645.  
  646.     UPROPERTY(BlueprintReadWrite, Category = "Climbing") // Read only
  647.     FVector ForwardVector;
  648.  
  649.     UPROPERTY(BlueprintReadOnly, Category = "Climbing")
  650.     FVector StopReachingVector;
  651.  
  652.     UPROPERTY(BlueprintReadOnly, Category = "Climbing")
  653.     double ClimbTransitionBlendTime;
  654.    
  655.     UPROPERTY(BlueprintReadOnly, Category = "Climbing")
  656.     bool bIsClimbReTransitioning;//
  657.  
  658.     // Free Climbing
  659.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  660.     bool bIsFreeClimbing;
  661.  
  662.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  663.     bool bIsFreeClimbingOnCeiling;
  664.  
  665.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  666.     bool bFreeClimbJumpOff;
  667.  
  668.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  669.     bool bIsFreeClimbDashing;
  670.  
  671.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  672.     bool bIsFreeClimbTurningCorner;
  673.  
  674.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  675.     bool bUsedClimbDashBackup;
  676.  
  677.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  678.     bool bFreeClimbTurnRight;
  679.  
  680.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  681.     bool bFreeClimbTurnInner;
  682.  
  683.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  684.     bool bIsFreeClimbSwinging;
  685.  
  686.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  687.     bool bIsFreeClimbSwingLeaping;
  688.  
  689.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  690.     bool bIsFreeClimbOnEdge;
  691.  
  692.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  693.     bool bFreeClimbTurnAround;
  694.  
  695.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  696.     bool bFreeClimbNotMoving;
  697.  
  698.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  699.     bool bFreeClimbToDashBackup;
  700.  
  701.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  702.     bool bFreeClimbToDash;
  703.  
  704.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  705.     bool bFreeClimbToTurnCorner;
  706.  
  707.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  708.     bool bIsFreeClimbingOnWall;
  709.  
  710.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  711.     bool bFreeClimbEnterFromTop;
  712.    
  713.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  714.     float FreeClimbTrueBlendValue = 0.2f;
  715.  
  716.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  717.     EMM_MovementMode FreeClimbFrom = EMM_MovementMode::OnGround;
  718.     bool bCheckedFreeClimbFrom;
  719.  
  720.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  721.     FVector2D FreeClimbDashVelocity;
  722.  
  723.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  724.     FVector2D FreeClimbInput;
  725.  
  726.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  727.     float FreeClimbIKAlpha;
  728.  
  729.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  730.     float FreeClimbSpeed;
  731.  
  732.     UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
  733.     float FreeClimbCeilingSpeed;
  734.    
  735.     UFUNCTION(Category = "Free Climb", BlueprintCallable, meta = (BlueprintThreadSafe))
  736.     void OnFreeClimbBecomeRelevant(const FAnimUpdateContext& Context, const FAnimNodeReference& Node);
  737.  
  738.     // Interaction and Character
  739.     UPROPERTY(BlueprintReadWrite, Category = "Motion Matching")
  740.     FTransform InteractionTransform;
  741.     UPROPERTY(BlueprintReadOnly, Category = "Character")
  742.     bool bIsKenyaCharacterValid;//
  743.     UPROPERTY(BlueprintReadOnly, Category = "Motion Matching")
  744.     FVector Trj_FutureVelocity = FVector::ZeroVector;
  745.     // Trajectory
  746.     UPROPERTY(BlueprintReadOnly, Category = "Trajectory")
  747.     FVector Trj_PastVelocity;
  748.  
  749.     UPROPERTY(BlueprintReadOnly, Category = "Trajectory")
  750.     FVector Trj_CurrentVelocity;
  751.    
  752.     // Character State
  753.     UPROPERTY(BlueprintReadWrite, Category = "Character") // Only Read
  754.     FTransform CharacterTransformLastFrame;
  755.  
  756.     UPROPERTY(BlueprintReadWrite, Category = "Character") // Only Read
  757.     FVector AccelerationLastFrame;
  758.     // Root Translation
  759.     UPROPERTY(BlueprintReadOnly, Category = "Root Translation")
  760.     double OffsetRootTranslationRadius;
  761.    
  762.     // Foot Placement Settings
  763.     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Foot Placement")
  764.     FFootPlacementPlantSettings PlantSettings_Default;
  765.  
  766.     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Foot Placement")
  767.     FFootPlacementPlantSettings PlantSettings_Stops;
  768.  
  769.     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Foot Placement")
  770.     FFootPlacementInterpolationSettings InterpolationSettings_Default;
  771.  
  772.     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Foot Placement")
  773.     FFootPlacementInterpolationSettings InterpolationSettings_Stops;
  774.  
  775.     /*
  776.      *FUNCTIONS CALLED FROM OTHER OBJS todo Run On Tick
  777.      */
  778.    
  779.     UFUNCTION(BlueprintPure, Category = "External Functions", meta = (BlueprintThreadSafe))
  780.     bool IsPivoting() const;
  781.     UFUNCTION(BlueprintPure, Category = "External Functions", meta = (BlueprintThreadSafe))
  782.     bool IsStarting();
  783.  
  784.     /*UFUNCTION(BlueprintPure, Category = "External Functions", meta = (BlueprintThreadSafe))
  785.     bool JustLanded_Light() const;*/
  786.     /*UFUNCTION(BlueprintPure, Category = "External Functions", meta = (BlueprintThreadSafe))
  787.     bool JustLanded_Heavy() const;*/
  788.    
  789.     UPROPERTY(BlueprintReadOnly, Category = "CHT | Variables")
  790.     bool bIsPivoting;
  791.     FORCEINLINE void IsPivotingUpdate()
  792.     {
  793.         FRotator Delta = FutureVelocity.ToOrientationRotator() - Velocity.ToOrientationRotator();
  794.         Delta.Normalize();
  795.         bIsPivoting = FMath::Abs( Delta.Yaw ) >= (RotationMode == EMM_RotationMode::OrientToMovement ? 60.f : 40.f);
  796.         /*todo More Optimized version to test
  797.          *bIsPivoting = FMath::Abs([&]() -> float {
  798.             const float d = (FMath::Atan2(FutureVelocity.Y, FutureVelocity.X) - FMath::Atan2(Velocity.Y, Velocity.X)) * 57.29578f;
  799.             return d > 180.f ? d - 360.f : d < -180.f ? d + 360.f : d;
  800.         }()) >= (RotationMode == EMM_RotationMode::OrientToMovement ? 60.f : 40.f);*/
  801.     }
  802.    
  803.     UPROPERTY(BlueprintReadOnly, Category = "CHT | Variables")
  804.     bool bIsStarting;
  805.     FORCEINLINE void IsStartingUpdate()
  806.     {
  807.         IsMovingUpdate();
  808.         bIsStarting = bIsMoving && (FutureVelocity.Size2D() >= Velocity.Size2D()+100) && !CurrentDatabaseTags.Contains(FName("Pivots"));
  809.     }
  810.    
  811.  
  812.     UPROPERTY(BlueprintReadOnly, Category = "CHT | Variables")
  813.     bool bJustLandedLight;
  814.     FORCEINLINE void JustLandedLightUpdate(){bJustLandedLight = bLocomotionLanded && FMath::Abs(LandVelocity.Z) < FMath::Abs(HeavyLandSpeedThreshold);}
  815.  
  816.     UPROPERTY(BlueprintReadOnly, Category = "CHT | Variables")
  817.     bool bJustLandedHeavy;
  818.     FORCEINLINE void JustLandedHeavyUpdate(){ bJustLandedHeavy =  bLocomotionLanded && FMath::Abs(LandVelocity.Z) >= FMath::Abs(HeavyLandSpeedThreshold) && !FloorActorTags.Contains("SlideSurface");}
  819.     bool JustLandedSprintingDoubleJump() const; //Not called from CHT
  820.  
  821.     // Sliding
  822.     UPROPERTY(BlueprintReadOnly, Category = "Sliding")
  823.     bool bIsSlidingDown;
  824.  
  825.     UPROPERTY(BlueprintReadWrite, Category = "Sliding")
  826.     ESlideType SlideType;
  827.  
  828.     UPROPERTY(BlueprintReadOnly, Category = "Sliding")
  829.     bool bWasSliding;
  830.  
  831.     UPROPERTY(BlueprintReadOnly, Category = "Sliding")
  832.     float SlidePitch;
  833.  
  834.     UPROPERTY(BlueprintReadOnly, Category = "Sliding")
  835.     bool bIsSlidingOrSlideJumping;
  836.  
  837.     //Pull Push
  838.     UPROPERTY(BlueprintReadOnly, Category = "Pull Push")
  839.     bool bIsPulling;
  840.  
  841.     //Beam
  842.     UPROPERTY(BlueprintReadOnly, Category = "Beam")
  843.     bool bEnableBeamWalk;
  844.  
  845.     UPROPERTY(BlueprintReadOnly, Category = "Beam")
  846.     bool bBeamWobble;
  847.  
  848.     /*
  849.      * ANIM GRAPH
  850.      */
  851.     UPROPERTY(BlueprintReadOnly, Category = "AnimGraph")
  852.     FQuat DesiredFacing;
  853.     FORCEINLINE void DesiredFacingUpdate()
  854.     {
  855.         FPoseSearchQueryTrajectorySample OutTrajectorySample;
  856.         UPoseSearchTrajectoryLibrary::GetTrajectorySampleAtTime(Trajectory, 0.5,OutTrajectorySample);
  857.         DesiredFacing = OutTrajectorySample.Facing;
  858.     }
  859.    
  860.     UPROPERTY(BlueprintReadOnly, Category = "Update Variables")
  861.     bool bIsMoving;
  862.  
  863.     UFUNCTION()
  864.     FORCEINLINE void IsMovingUpdate()
  865.     {
  866.         constexpr float Threshold = 0.1f;
  867.         bIsMoving = !Velocity.Equals( FVector::ZeroVector, Threshold) && !FutureVelocity.Equals( FVector::ZeroVector, Threshold);
  868.     }
  869.  
  870.     UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Offset Root Bone", meta = (BlueprintThreadSafe))
  871.     bool IsMoving() const;
  872.  
  873.     UPROPERTY(BlueprintReadOnly, Category = "Update Variables")
  874.     float MMBlendTime;
  875.     UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Offset Root Bone", meta = (BlueprintThreadSafe))
  876.     float Get_MMBlendTimeUpdate() const;
  877.     FORCEINLINE void MMBlendTimeUpdate()
  878.     {
  879.         switch (MovementMode) {
  880.             case EMM_MovementMode::OnGround:
  881.             //if ((PreviousGroundedGait == EMM_Gait::Run or PreviousGroundedGait == EMM_Gait::Sprint) && Gait ==  EMM_Gait::Walk){return 0.4f;}
  882.             switch (MovementMode_LastFrame)
  883.                 {
  884.                     case EMM_MovementMode::OnGround:
  885.                         MMBlendTime = 0.4f;
  886.                                 break;
  887.                     case EMM_MovementMode::InAir:
  888.                         MMBlendTime = 0.2f;
  889.                                 break;
  890.                 }
  891.             break;
  892.             case EMM_MovementMode::InAir:
  893.             if (Velocity.Z > 100.0f)
  894.             {
  895.                 MMBlendTime = 0.15f;
  896.             }
  897.             MMBlendTime =0.5f;
  898.             break;
  899.         }
  900.     }
  901.    
  902.    
  903.     UPROPERTY(BlueprintReadOnly, Category = "Update Variables")
  904.     float MMNotifyRecencyTimeout;
  905.     UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Offset Root Bone", meta = (BlueprintThreadSafe))
  906.     float Get_MMNotifyRecencyTimeoutUpdate() const;
  907.     FORCEINLINE void MMNotifyRecencyTimeoutUpdate()
  908.     {
  909.         switch (Gait)
  910.         {
  911.         case EMM_Gait::Walk:
  912.             MMNotifyRecencyTimeout = 0.2f;
  913.             break;
  914.         case EMM_Gait::Run:
  915.             MMNotifyRecencyTimeout = 0.2f;
  916.             break;
  917.         case EMM_Gait::Sprint:
  918.             MMNotifyRecencyTimeout = 0.16f;
  919.             break;
  920.         }
  921.     }
  922.     EPoseSearchInterruptMode Get_MMInterrupt() const;
  923.  
  924.     UFUNCTION(Category = "MotionMatching", BlueprintCallable, meta = (BlueprintThreadSafe))
  925.     void Update_MotionMatchingDBS(const FAnimUpdateContext& Context, const FAnimNodeReference& Node);
  926.     UFUNCTION(Category = "MotionMatching", BlueprintCallable, meta = (BlueprintThreadSafe))
  927.     void Update_MotionMatchingPostSelection(const FAnimUpdateContext& Context, const FAnimNodeReference& Node);
  928.    
  929.     UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Motion Matching", meta = (BlueprintThreadSafe))
  930.     FVector2D Get_LeanAmount() const;
  931.  
  932.     UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Offset Root Bone", meta = (BlueprintThreadSafe))
  933.     EOffsetRootBoneMode Get_OffsetRootTranslationMode() const;
  934.     UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Offset Root Bone", meta = (BlueprintThreadSafe))
  935.     EOffsetRootBoneMode Get_OffsetRootRotationMode()  const;
  936.     UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Offset Root Bone", meta = (BlueprintThreadSafe))
  937.     float Get_OffsetRootTranslationHalfLife() const;
  938.    
  939.     UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Foot Placement", meta = (BlueprintThreadSafe))
  940.     FFootPlacementInterpolationSettings Get_FootPlacementInterpolationSettings()  const;
  941.     UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Foot Placement", meta = (BlueprintThreadSafe))
  942.     FFootPlacementPlantSettings Get_FootPlacementPlantSettings() const;
  943.  
  944.     UFUNCTION(BlueprintPure, Category = "Motion Matching", meta = (BlueprintThreadSafe))
  945.     FVector CalculateRelativeAccelerationAmount() const;
  946.  
  947.     UPROPERTY(BlueprintReadOnly, Category = "AnimGraph | Blend Stack Input")
  948.     EOrientationWarpingSpace OrientationWarpingSpace;
  949.     FORCEINLINE void OrientationWarpingWarpingSpaceUpdate()
  950.     {
  951.         OrientationWarpingSpace = bOffsetRootBoneEnabled ? EOrientationWarpingSpace::RootBoneTransform : EOrientationWarpingSpace::ComponentTransform;
  952.     }
  953.     /*UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Blend Stack Input", meta = (BlueprintThreadSafe))
  954.     EOrientationWarpingSpace Get_OrientationWarpingWarpingSpaceN() const;*/
  955.  
  956.     UPROPERTY(BlueprintReadOnly, Category = "AnimGraph | Blend Stack Input")
  957.     bool bEnableSteering;
  958.     FORCEINLINE void EnableSteeringUpdate() {
  959.         bEnableSteering = MovementState == EMM_MovementState::Moving or MovementMode == EMM_MovementMode::OnGround;
  960.     }
  961.     /*float LeanTimer;
  962.     UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Leaning")
  963.     float MaxLeanDuration = 2.0f; */
  964.     UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Offset Root Bone", meta = (BlueprintThreadSafe))
  965.     float Get_RightLean();
  966. #pragma region Delegates
  967.    
  968.     UPROPERTY()
  969.     UAbilityAsync_WaitGameplayEvent* OnLandingTask;
  970.     UFUNCTION(BlueprintCallable)
  971.     void OnLandingEventReceived(FGameplayEventData Payload);
  972.     FTimerHandle LandingResetTimerHandle;
  973.    
  974.     UFUNCTION()
  975.     void HardLandingOnRollMontageBlendOut(UAnimMontage* Montage, bool bInterrupted);
  976.     UPROPERTY()
  977.     UAbilityAsync_WaitGameplayEvent* OnJumpDoubleTask;
  978.     UFUNCTION(BlueprintCallable)
  979.     void OnJumpDoubleTaskReceived(FGameplayEventData Payload);
  980.     FTimerHandle DoubleJumpTimerHandle;
  981.    
  982.     UPROPERTY()
  983.     UAbilityAsync_WaitGameplayEvent* OnAirDashTask;
  984.     UFUNCTION(BlueprintCallable)
  985.     void OnAirDashTaskReceived(FGameplayEventData Payload);
  986.  
  987.     UPROPERTY()
  988.     UAbilityAsync_WaitGameplayEvent* OnClimbBeginTask;
  989.     UFUNCTION(BlueprintCallable)
  990.     void OnClimbBeginTaskReceived(FGameplayEventData Payload);
  991.     UFUNCTION(BlueprintCallable)
  992.     void OnClimbBegin();
  993.    
  994.     UPROPERTY()
  995.     UAbilityAsync_WaitGameplayEvent* OnClimbReachBeginTask;
  996.    
  997.    
  998.     UPROPERTY()
  999.     UAbilityAsync_WaitGameplayEvent* OnClimbReachFinishedTask;
  1000.     UFUNCTION(BlueprintCallable)
  1001.     void OnClimbReachFinishedTaskReceived(FGameplayEventData Payload);
  1002.  
  1003.     UPROPERTY()
  1004.     UAbilityAsync_WaitGameplayEvent* OnClimbTransitionTask;
  1005.     UFUNCTION(BlueprintCallable)
  1006.     void OnClimbTransitionTaskReceived(FGameplayEventData Payload);
  1007.     FTimerHandle ClimbTransitionTimerHandle;
  1008.    
  1009.     UPROPERTY()
  1010.     UAbilityAsync_WaitGameplayEvent* OnPerchTurnEndedTask;
  1011.     UFUNCTION(BlueprintCallable)
  1012.     void OnPerchTurnEndedTaskReceived(FGameplayEventData Payload);
  1013.     FTimerHandle PerchTurnEndedTimerHandle;
  1014.    
  1015.     UPROPERTY()
  1016.     UAbilityAsync_WaitGameplayEvent* OnStandBeginTask;
  1017.     UFUNCTION(BlueprintCallable)
  1018.     void OnStandBeginTaskReceived(FGameplayEventData Payload);
  1019.  
  1020.     UPROPERTY()
  1021.     UAbilityAsync_WaitGameplayTagAdded* OnFreeClimbJumpTagAddedTask;
  1022.  
  1023.     UFUNCTION(BlueprintCallable)
  1024.     void OnFreeClimbJumpTagAddedTaskReceived();
  1025.  
  1026.     UPROPERTY()
  1027.     UAbilityAsync_WaitGameplayTagRemoved* OnFreeClimbJumpTagRemovedTask;
  1028.  
  1029.     UFUNCTION(BlueprintCallable)
  1030.     void OnFreeClimbJumpTagRemovedTaskReceived();
  1031.  
  1032. #pragma endregion
  1033.  
  1034.     //BlendStack
  1035.     UFUNCTION(Category = "BlendStack", BlueprintCallable, meta = (BlueprintThreadSafe))
  1036.     void UpdateBlendStack(const FAnimUpdateContext& Context, const FAnimNodeReference& Node);
  1037.    
  1038.     UPROPERTY(BlueprintReadOnly, Category = "Motion Matching")
  1039.     float AnimTime;
  1040.     UPROPERTY(BlueprintReadOnly, Category = "Motion Matching")
  1041.     TObjectPtr<UAnimationAsset> AnimAsset;
  1042.  
  1043.     UPROPERTY(BlueprintReadOnly, Category = "Motion Matching")
  1044.     float OrientationAlpha;
  1045.  
  1046.  
  1047.     //Test
  1048.     UFUNCTION(BlueprintNativeEvent)
  1049.     void TaskTestTiming();
  1050.  
  1051.     UFUNCTION(BlueprintCallable)
  1052.     bool CheckCombatStance() const;
  1053.  
  1054.     UFUNCTION(BlueprintCallable)
  1055.     void CheckCombatStanceV();
  1056.  
  1057.     UPROPERTY(BlueprintReadWrite)
  1058.     bool bCombatStance;
  1059.  
  1060.     UFUNCTION(Category = "BlendStack", BlueprintCallable, meta = (BlueprintThreadSafe))
  1061.     void UpdateOffSetRootNode( const FAnimUpdateContext& Context, const FAnimNodeReference& Node);
  1062.  
  1063.     bool bInitialized;
  1064.  
  1065.     UPROPERTY(BlueprintReadOnly)
  1066.     UBlendSpace* CurrentLeanBlendMontage;
  1067.  
  1068.     UPROPERTY(EditDefaultsOnly)
  1069.     TObjectPtr<UBlendSpace> WalkLeanBlendMontage;
  1070.  
  1071.     UPROPERTY(EditDefaultsOnly)
  1072.     TObjectPtr<UBlendSpace> RunLeanBlendMontage;
  1073.  
  1074.     UPROPERTY(EditDefaultsOnly)
  1075.     TObjectPtr<UBlendSpace> SprintLeanBlendMontage;
  1076.  
  1077.     UPROPERTY(EditDefaultsOnly)
  1078.     TObjectPtr<UBlendSpace> CombatWalkLeanBlendMontage;
  1079.  
  1080.     UPROPERTY(EditDefaultsOnly)
  1081.     TObjectPtr<UBlendSpace> CombatRunLeanBlendMontage;
  1082.  
  1083.     UPROPERTY(EditDefaultsOnly)
  1084.     TObjectPtr<UBlendSpace> CombatSprintLeanBlendMontage;
  1085.  
  1086.     UPROPERTY(EditDefaultsOnly)
  1087.     float BlendSpaceAmount = 1;
  1088.  
  1089.     UFUNCTION(Category = "MotionMatching", BlueprintCallable, meta = (BlueprintThreadSafe))
  1090.     void OnZiplineInitialUpdate(const FAnimUpdateContext& Context, const FAnimNodeReference& Node);
  1091.  
  1092. protected:
  1093.     UPROPERTY(BlueprintReadOnly)
  1094.     bool bIsPossessingRobot = false;
  1095. };
  1096.  
  1097. [CPP]
  1098. void FTPAnimInstanceProxy::InitializeObjects(UAnimInstance* InAnimInstance)
  1099. {
  1100.     FAnimInstanceProxy::InitializeObjects(InAnimInstance);
  1101.     Character = Cast<ASDKenyaCharacter>(InAnimInstance->TryGetPawnOwner());
  1102.     if (!Character.Get()) return;
  1103.     CharacterMovement = Cast<USDCharacterMovementComponent>(Character->GetCharacterMovement());
  1104. }
  1105.  
  1106. void FTPAnimInstanceProxy::PreUpdate(UAnimInstance* InAnimInstance, const float DeltaSeconds)
  1107. {
  1108.     FAnimInstanceProxy::PreUpdate(InAnimInstance, DeltaSeconds);
  1109. }
  1110.  
  1111. void FTPAnimInstanceProxy::Update(const float DeltaSeconds)
  1112. {
  1113.     FAnimInstanceProxy::Update(DeltaSeconds);
  1114. }
  1115.  
  1116. void USDKenyaAnimInstance::NativeInitializeAnimation()
  1117. {
  1118.     Super::NativeInitializeAnimation();
  1119.     EmptyArray.Reserve(0);
  1120.     Character = Cast<ASDKenyaCharacter>(TryGetPawnOwner());
  1121.     if (!Character) return;
  1122.     //GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Blue, TEXT(""));
  1123.     CharacterMovement = Character->GetCharacterMovement();
  1124.  
  1125.     FTimerHandle TimerWait;
  1126.     GetWorld()->GetTimerManager().SetTimer(TimerWait, FTimerDelegate::CreateWeakLambda(this, [this]()
  1127.     {
  1128.         bInitialized = true;
  1129.     }), 0.1, false);
  1130.  
  1131.     OnFreeClimbJumpTagAddedTask = UAbilityAsync_WaitGameplayTagAdded::WaitGameplayTagAddToActor(Character, FGameplayTag::RequestGameplayTag(FName("AbilityEvent.AnimNotify.Character.FreeClimb.JumpOff")));
  1132.     OnFreeClimbJumpTagAddedTask->Added.AddDynamic(this, &USDKenyaAnimInstance::OnFreeClimbJumpTagAddedTaskReceived);
  1133.  
  1134.     OnFreeClimbJumpTagRemovedTask = UAbilityAsync_WaitGameplayTagRemoved::WaitGameplayTagRemoveFromActor(Character, FGameplayTag::RequestGameplayTag(FName("AbilityEvent.AnimNotify.Character.FreeClimb.JumpOff")));
  1135.     OnFreeClimbJumpTagRemovedTask->Removed.AddDynamic(this, &USDKenyaAnimInstance::OnFreeClimbJumpTagRemovedTaskReceived);
  1136. }
  1137.  
  1138. void USDKenyaAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
  1139. {
  1140.     if (!bInitialized) return;
  1141.     //BP Native Event Fixes **GAME THREAD**
  1142.     //EssentialValueFix();
  1143.    
  1144.     //CHT Updates **GAME THREAD**
  1145.     if (MovementMode == EMM_MovementMode::OnGround)
  1146.     {
  1147.         JustLandedLightUpdate();
  1148.         JustLandedHeavyUpdate();
  1149.         CheckCombatStanceV();
  1150.         if (MovementState == EMM_MovementState::Moving )
  1151.         {
  1152.             IsStartingUpdate();
  1153.             IsPivotingUpdate();
  1154.             IsStartingUpdate();
  1155.         }
  1156.     }
  1157.     //Core ST Option
  1158.     //UpdateEssentialValueST(DeltaSeconds);
  1159.     //GenerateTrajectoryST(DeltaSeconds);
  1160.     //TaskTestTiming();
  1161.     //UpdateStatesST();
  1162.     //SetMotionMatchingDB();
  1163.     //CHT Variables to update on **GAME THREAD**GEngine->AddOnScreenDebugMessage(-1, 0.f, FColor::Blue, FString::Printf(TEXT("Speed: %f"),Speed2D));
  1164. }
  1165.  
  1166. void USDKenyaAnimInstance::NativeThreadSafeUpdateAnimation(float DeltaSeconds)
  1167. {
  1168.     if (!bInitialized) return;
  1169.  
  1170.     //AnimGraph Variable Updates
  1171.     /*MMBlendTimeUpdate();
  1172.     MMNotifyRecencyTimeoutUpdate();*/
  1173.     GetIsAirDashOrIsDoubleAirDash();
  1174.     //GetSlidingDownFalseBlendValue(); Apparently not used anymore
  1175.     IsMovingUpdate();
  1176.    
  1177.     //Motion Matching Core
  1178.     UpdateEssentialValue(DeltaSeconds);
  1179.     UpdateWallRunValues(DeltaSeconds);
  1180.     UpdateFreeClimbValues(DeltaSeconds);
  1181.     UpdateSlideValues(DeltaSeconds);
  1182.     UpdatePullPushValues(DeltaSeconds);
  1183.     UpdateBeamWalkValues(DeltaSeconds);
  1184.     GenerateTrajectory(DeltaSeconds);
  1185.     UpdateStates();
  1186.     SetMotionMatchingDB();
  1187.     IdleAimOffsetYawPitchUpdate(DeltaSeconds);
  1188.     idleTurnInplaceTick();
  1189.     // PsycheScan Turn in place system
  1190.     UpdateRotationData();
  1191.     UpdateRootYawOffset(DeltaSeconds);
  1192.     //UpdateRotationData();
  1193.    
  1194.     //GEngine->AddOnScreenDebugMessage(-1, 0.f, FColor::Blue, FString::Printf(TEXT("Speed: %f"),Speed2D));
  1195.     //
  1196.     bIsPossessingRobot = Character->GetAbilitySystemComponent()->HasMatchingGameplayTag(FGameplayTag::RequestGameplayTag(FName("Status.Psyche.Nocked")));
  1197. }
  1198.  
  1199. void USDKenyaAnimInstance::SetMotionMatchingDB()
  1200. {
  1201.     MotionMatchingDB_LastFrame = MotionMatchingDB;
  1202.     switch (OverlayState) {
  1203.         case EOverlayState::Unarmed:
  1204.         case EOverlayState::Powercell:
  1205.             //MotionMatchingDB = E_KenyaMotionMatchingDB::Normal;
  1206.             MotionMatchingDB = bCombatStance ? E_KenyaMotionMatchingDB::Combat : E_KenyaMotionMatchingDB::Normal;
  1207.  
  1208.             CurrentCHT = bCombatStance ? CombatCHT : MainCHT;
  1209.             break;
  1210.         case EOverlayState::Scan:
  1211.             MotionMatchingDB = E_KenyaMotionMatchingDB::Psyche;
  1212.             CurrentCHT = PsycheCHT;
  1213.             break;
  1214.         case EOverlayState::Minigun:
  1215.             MotionMatchingDB = E_KenyaMotionMatchingDB::Minigun;
  1216.             CurrentCHT = MiniGunCHT;
  1217.             break;
  1218.     }
  1219. }
  1220.  
  1221. void USDKenyaAnimInstance::UpdatePullPushValues(const float DeltaSeconds)
  1222. {
  1223.     bIsPulling = Proxy.Character->GetAbilitySystemComponent()->HasMatchingGameplayTag(FGameplayTag::RequestGameplayTag(FName("Ability.Combat.Pull")));
  1224. }
  1225.  
  1226. void USDKenyaAnimInstance::UpdateBeamWalkValues(const float DeltaSeconds)
  1227. {
  1228.     if (!Proxy.Character->BeamComponent)
  1229.         return;
  1230.  
  1231.     bEnableBeamWalk = Proxy.Character->BeamComponent->bBeamWalkEnable;
  1232.     bBeamWobble = Proxy.Character->BeamComponent->bAtEndOfBeam;
  1233. }
  1234.  
  1235. FTransform USDKenyaAnimInstance::GetInteractionTransform() const
  1236. {
  1237.     return InteractionTransform;
  1238. }
  1239.  
  1240. void USDKenyaAnimInstance::SetInteractionTransform(FTransform SetTransform)
  1241. {
  1242.     InteractionTransform=SetTransform;
  1243. }
  1244.  
  1245. void USDKenyaAnimInstance::GenerateTrajectory(const float DeltaSeconds)
  1246. {
  1247.     UPoseSearchTrajectoryLibrary::PoseSearchGenerateTrajectory(this, Speed2D > 0 ? TrajectoryGenerationData_Moving : TrajectoryGenerationData_Idle,
  1248.         DeltaSeconds, Trajectory, PreviousDesiredControllerYaw,Proxy.OutTrajectory, -1.0,
  1249.         30,0.071,15 );
  1250.     // collison check is causing incorrect jump mechanics for climbing
  1251.     UPoseSearchTrajectoryLibrary::HandleTrajectoryWorldCollisions(Proxy.Character.Get(), this, Proxy.OutTrajectory, true, 0.01, Trajectory , TrajectoryCollision,
  1252.          ETraceTypeQuery::TraceTypeQuery1, false, EmptyArray,  EDrawDebugTrace::None,true, 150);
  1253.     UPoseSearchTrajectoryLibrary::GetTrajectorySampleAtTime(Trajectory,0.5, Proxy.OutTrajectorySample1);
  1254.     UPoseSearchTrajectoryLibrary::GetTrajectorySampleAtTime(Trajectory,0.4,Proxy.OutTrajectorySample2);
  1255.    
  1256.     FutureVelocity = (Proxy.OutTrajectorySample1.Position - Proxy.OutTrajectorySample2.Position) * 10.0f;
  1257. }
  1258.  
  1259. void USDKenyaAnimInstance::UpdateEssentialValue(const float DeltaSeconds)
  1260. {
  1261.     //0)
  1262.     CharacterTransformLastFrame = CharacterTransform;
  1263.     CharacterTransform = Proxy.Character->GetActorTransform();
  1264.     //1)
  1265.     bOffsetRootBoneEnabled = true; //UKismetSystemLibrary::GetConsoleVariableBoolValue("a.animnode.offsetrootbone.enable"); todo WEIRD BP CODE
  1266.     if (bOffsetRootBoneEnabled)
  1267.     {
  1268.         //UpdateRootBoneTransformFix();
  1269.         /*FRotator OffsetRotation = AnimNodeOffsetRootTransform.Rotator();
  1270.         OffsetRotation.Yaw += 90.0f;
  1271.         RootTransform = FTransform(OffsetRotation,  AnimNodeOffsetRootTransform.GetLocation(), FVector(1.0f, 1.0f, 1.0f));*/
  1272.         const FTransform AnimNodeRootTransform  = UAnimationWarpingLibrary::GetOffsetRootTransform(UpdateRootBoneNode);
  1273.         FRotator OffsetRotation = AnimNodeRootTransform.Rotator();
  1274.         OffsetRotation.Yaw += 90.0f;
  1275.         RootTransform = FTransform(OffsetRotation,  AnimNodeRootTransform.GetLocation(), FVector(1.0f, 1.0f, 1.0f));
  1276.     } else
  1277.     {
  1278.         RootTransform = CharacterTransform;
  1279.     }
  1280.     //2)
  1281.     AccelerationLastFrame = Acceleration;
  1282.     Acceleration = Proxy.CharacterMovement->GetCurrentAcceleration();
  1283.     AccelerationAmount = Acceleration.Size() / Proxy.CharacterMovement->MaxAcceleration;
  1284.     bHasAcceleration = AccelerationAmount > 0.f;
  1285.     //3)
  1286.     VelocityLastFrame = Velocity;
  1287.     Velocity = Proxy.CharacterMovement->Velocity;
  1288.     Speed2D = Velocity.Size2D();
  1289.     bHasVelocity = Speed2D > 5.f;
  1290.  
  1291.     VelocityAcceleration =  (Velocity - VelocityLastFrame) / DeltaSeconds;
  1292.     if (bHasVelocity) LastNonZeroVelocity = Velocity;
  1293.     //4)
  1294.     AwarenessSpineRotator = Proxy.Character->AwarenessSpineRotator;
  1295.     AwarenessSpineRotation = FMath::FInterpTo(AwarenessSpineRotation, AwarenessSpineRotator, DeltaSeconds, 4.5);//todo 6 seems to fast
  1296.     AwarenessSpineRotationNegative = AwarenessSpineRotation * -1.0;
  1297.     //5)
  1298.     if (Proxy.Character->OverlayStateN != OverlayState)
  1299.     {
  1300.         PreviousOverlayState = OverlayState;
  1301.         OverlayState = Proxy.Character->OverlayStateN;
  1302.     }
  1303.     //6)
  1304.     InputVector = Proxy.CharacterMovement->GetLastInputVector().GetClampedToSize(0, 1);
  1305.     ForwardVector = Proxy.Character->GetActorForwardVector();
  1306.     RightVector = Proxy.Character->GetActorRightVector();
  1307.  
  1308.     bIsOnGround = Proxy.CharacterMovement->IsMovingOnGround();
  1309. }
  1310.  
  1311. void USDKenyaAnimInstance::UpdateWallRunValues(const float DeltaSeconds) {
  1312.     if (!Proxy.Character->WallRunAbility) return;
  1313.  
  1314.     // Now safe to access WallRunAbility
  1315.     bIsWallRunning = Proxy.Character->WallRunAbility->bIsWallRunning;
  1316.     bIsWallJumping = Proxy.Character->WallRunAbility->bIsWallJumping;
  1317.     bIsWallRunningORJumping = bIsWallRunning || bIsWallJumping;
  1318.     bIsDoubleJump = (bIsWallRunning) ? false : bIsDoubleJump;
  1319.     bIsAirDashOrIsDoubleAirDash = (bIsWallRunning) ? false : bIsAirDashOrIsDoubleAirDash;
  1320.     bIsWallRunningNORJumping = !bIsWallRunningORJumping;
  1321.    
  1322.     WallSide = Proxy.Character->WallRunAbility->WallSide;
  1323.     bIsWallSideRight = WallSide == EWallRunDirection::Right;
  1324.     bIsWallSideLeft = !bIsWallSideRight;
  1325.    
  1326.     CurrentArcAngle = Proxy.Character->WallRunAbility->CurrentArcAngle;
  1327.     CurrentTurnRate = Proxy.Character->WallRunAbility->CurrentTurnRate;
  1328.     WallJumpHorizontalVelocity = Proxy.Character->WallRunAbility->WallJumpHorizontalVelocity;
  1329.     WallJumpVerticalVelocity = Proxy.Character->WallRunAbility->WallJumpVerticalVelocity;
  1330.     CurrentSpeed = Proxy.Character->GetVelocity().Length();
  1331.  
  1332.     // Set how fast the run animation plays according to how fast the character is moving. 800 movement speed = default animation speed. The animation can only go +/- 15% speed to prevent it from looking ridiculous at very high or very low movement speeds.
  1333.     WallRunAnimPlayRate = FMath::GetMappedRangeValueClamped(FVector2D(935, 1265), FVector2D(1.f, 1.3f), CurrentSpeed);
  1334.     // The speed of the wall jump animation is increased relative to the desired speed of the wall jump. This improves the look of higher speed wall jumps because the animation will better match the faster movement. The bottom value is 943 because that is the vector length of the default wall jump velocity.
  1335.     WallJumpAnimationSpeed = FMath::GetMappedRangeValueClamped(FVector2D(943.f, 1500.f), FVector2D(1.0, 1.5), FVector(0, WallJumpHorizontalVelocity, WallJumpVerticalVelocity).Length());
  1336.     // Calculate an alpha value (0-1) that will be used for the hand correction additive pose. This additive pose is an aid to help the hand position remain consistent during the arcing wall run blendspace. Without this, the hand will clip into the wall between 0 and 45 degrees in the blendspace.
  1337.     const float TargetAdditive = (CurrentArcAngle >= 15.f) ?
  1338.         FMath::GetMappedRangeValueClamped(FVector2D(30.f,45.f), FVector2D(1.f, 0.f), CurrentArcAngle) :
  1339.         FMath::GetMappedRangeValueClamped(FVector2D(0.f, 30.f), FVector2d(0.0f, 1.f), CurrentArcAngle);
  1340.     HandCorrectionAdditive = FMath::FInterpTo(HandCorrectionAdditive, TargetAdditive, DeltaSeconds, 7.f);
  1341. }
  1342.  
  1343. void USDKenyaAnimInstance::UpdateFreeClimbValues(const float DeltaSeconds)
  1344. {
  1345.     //Update Free Climb Transition Bools
  1346.    
  1347.     bIsFreeClimbing = Proxy.CharacterMovement->IsFreeClimbing();
  1348.     bIsFreeClimbingOnCeiling = Proxy.CharacterMovement->IsFreeClimbOnCeiling();
  1349.     bIsFreeClimbDashing = Proxy.CharacterMovement->IsFreeClimbDashing();
  1350.     bIsFreeClimbTurningCorner = Proxy.CharacterMovement->bIsTurningCorner;
  1351.     bIsFreeClimbSwinging = Proxy.CharacterMovement->IsSwinging();
  1352.     bIsFreeClimbSwingLeaping = Proxy.CharacterMovement->IsSwingLeaping();
  1353.     bIsFreeClimbOnEdge = Proxy.CharacterMovement->IsAtEdge();
  1354.     bFreeClimbTurnAround = Proxy.CharacterMovement->ShouldTurnAround();
  1355.     bIsFreeClimbingOnWall = bIsFreeClimbing && !bIsFreeClimbingOnCeiling;
  1356.     bFreeClimbEnterFromTop = Proxy.CharacterMovement->EnteredClimbFromTop();
  1357.     FreeClimbTrueBlendValue = bFreeClimbEnterFromTop ? 0.0f : 0.2f;
  1358.     FreeClimbSpeed = Proxy.CharacterMovement->GetFreeClimbMaxSpeed();
  1359.     FreeClimbCeilingSpeed = Proxy.CharacterMovement->GetCeilingFreeClimbMaxSpeed();
  1360.     Proxy.CharacterMovement->GetTurningType(bFreeClimbTurnRight, bFreeClimbTurnInner);
  1361.     FreeClimbIKAlpha = GetCurveValue(FName("EnableFreeClimbIK"));
  1362.  
  1363.     bFreeClimbToDashBackup = bIsFreeClimbDashing && !bIsFreeClimbTurningCorner && bUsedClimbDashBackup;
  1364.     bFreeClimbToDash = bIsFreeClimbDashing && !bIsFreeClimbTurningCorner && !bUsedClimbDashBackup;
  1365.     bFreeClimbToTurnCorner = bIsFreeClimbDashing && bIsFreeClimbTurningCorner;
  1366.  
  1367.     //Update FreeClimbFrom
  1368.     if (!bIsFreeClimbing)
  1369.     {
  1370.         bCheckedFreeClimbFrom = false;
  1371.         return;
  1372.     }
  1373.  
  1374.     if (!bCheckedFreeClimbFrom)
  1375.     {
  1376.         FreeClimbFrom = MovementMode_LastFrame;
  1377.         bCheckedFreeClimbFrom = true;
  1378.     }
  1379.  
  1380.     //Update FreeClimbDashVelocity
  1381.     const FVector UnrotatedDashVec = Proxy.Character->GetActorRotation().UnrotateVector(Proxy.CharacterMovement->GetFreeClimbDashDirection());
  1382.     if (bIsFreeClimbingOnCeiling)
  1383.         FreeClimbDashVelocity = FVector2D(UnrotatedDashVec.Y, UnrotatedDashVec.X);
  1384.     else
  1385.         FreeClimbDashVelocity = FVector2D(UnrotatedDashVec.Y, UnrotatedDashVec.Z);
  1386.  
  1387.     //Update FreeClimbDirection
  1388.     FreeClimbInput = FVector2D(Proxy.Character->MoveRightInputRawValue, Proxy.Character->MoveForwardInputRawValue);
  1389.  
  1390.     const FVector UnrotatedVelVec = Proxy.Character->GetActorRotation().UnrotateVector(Proxy.CharacterMovement->Velocity);
  1391.     FVector2D FreeClimbVelocity;
  1392.     if (bIsFreeClimbingOnCeiling)
  1393.         FreeClimbVelocity = FVector2D(UnrotatedVelVec.X, UnrotatedVelVec.Y) * 0.0083f;
  1394.     else
  1395.         FreeClimbVelocity = FVector2D(UnrotatedVelVec.Y, UnrotatedVelVec.Z) * 0.0083f;
  1396.  
  1397.     const bool bHasTag = Proxy.Character->GetAbilitySystemComponent()->HasMatchingGameplayTag(FGameplayTag::RequestGameplayTag(FName("AbilityEvent.Character.FreeClimb.Enter")));
  1398.     if (FreeClimbVelocity.Length() < 0.01f || bHasTag)
  1399.         FreeClimbInput = FVector2D::ZeroVector;
  1400.  
  1401.     bFreeClimbNotMoving = FreeClimbInput.Length() <= 0.0f;
  1402.    
  1403.     /*bIsFreeClimbing = Proxy.Character->SDCharacterMovementComponent->IsFreeClimbing();
  1404.     bIsFreeClimbingOnCeiling = Proxy.Character->SDCharacterMovementComponent->IsFreeClimbOnCeiling();
  1405.     bIsFreeClimbDashing = Proxy.Character->SDCharacterMovementComponent->IsFreeClimbDashing();
  1406.     bIsFreeClimbTurningCorner = Proxy.Character->SDCharacterMovementComponent->bIsTurningCorner;
  1407.     bIsFreeClimbSwinging = Proxy.Character->SDCharacterMovementComponent->IsSwinging();
  1408.     bIsFreeClimbSwingLeaping = Proxy.Character->SDCharacterMovementComponent->IsSwingLeaping();
  1409.     bIsFreeClimbOnEdge = Proxy.Character->SDCharacterMovementComponent->IsAtEdge();
  1410.     bFreeClimbTurnAround = Proxy.Character->SDCharacterMovementComponent->ShouldTurnAround();
  1411.     bIsFreeClimbingOnWall = bIsFreeClimbing && !bIsFreeClimbingOnCeiling;
  1412.     bFreeClimbEnterFromTop = Proxy.Character->SDCharacterMovementComponent->EnteredClimbFromTop();
  1413.     FreeClimbTrueBlendValue = bFreeClimbEnterFromTop ? 0.0f : 0.2f;
  1414.     FreeClimbSpeed = Proxy.Character->SDCharacterMovementComponent->GetFreeClimbMaxSpeed();
  1415.     FreeClimbCeilingSpeed = Proxy.Character->SDCharacterMovementComponent->GetCeilingFreeClimbMaxSpeed();
  1416.     Proxy.Character->SDCharacterMovementComponent->GetTurningType(bFreeClimbTurnRight, bFreeClimbTurnInner);
  1417.     FreeClimbIKAlpha = GetCurveValue(FName("EnableFreeClimbIK"));
  1418.  
  1419.     bFreeClimbToDashBackup = bIsFreeClimbDashing && !bIsFreeClimbTurningCorner && bUsedClimbDashBackup;
  1420.     bFreeClimbToDash = bIsFreeClimbDashing && !bIsFreeClimbTurningCorner && !bUsedClimbDashBackup;
  1421.     bFreeClimbToTurnCorner = bIsFreeClimbDashing && bIsFreeClimbTurningCorner;
  1422.  
  1423.     //Update FreeClimbFrom
  1424.     if (!bIsFreeClimbing)
  1425.     {
  1426.         bCheckedFreeClimbFrom = false;
  1427.         return;
  1428.     }
  1429.  
  1430.     if (!bCheckedFreeClimbFrom)
  1431.     {
  1432.         FreeClimbFrom = MovementMode_LastFrame;
  1433.         bCheckedFreeClimbFrom = true;
  1434.     }
  1435.  
  1436.     //Update FreeClimbDashVelocity
  1437.     const FVector UnrotatedDashVec = Proxy.Character->GetActorRotation().UnrotateVector(Proxy.Character->SDCharacterMovementComponent->GetFreeClimbDashDirection());
  1438.     if (bIsFreeClimbingOnCeiling)
  1439.         FreeClimbDashVelocity = FVector2D(UnrotatedDashVec.Y, UnrotatedDashVec.X);
  1440.     else
  1441.         FreeClimbDashVelocity = FVector2D(UnrotatedDashVec.Y, UnrotatedDashVec.Z);
  1442.  
  1443.     //Update FreeClimbDirection
  1444.     FreeClimbInput = FVector2D(Proxy.Character->MoveRightInputRawValue, Proxy.Character->MoveForwardInputRawValue);
  1445.  
  1446.     const FVector UnrotatedVelVec = Proxy.Character->GetActorRotation().UnrotateVector(Proxy.CharacterMovement->Velocity);
  1447.     FVector2D FreeClimbVelocity;
  1448.     if (bIsFreeClimbingOnCeiling)
  1449.         FreeClimbVelocity = FVector2D(UnrotatedVelVec.X, UnrotatedVelVec.Y) * 0.0083f;
  1450.     else
  1451.         FreeClimbVelocity = FVector2D(UnrotatedVelVec.Y, UnrotatedVelVec.Z) * 0.0083f;
  1452.  
  1453.     const bool bHasTag = Proxy.Character->GetAbilitySystemComponent()->HasMatchingGameplayTag(FGameplayTag::RequestGameplayTag(FName("AbilityEvent.Character.FreeClimb.Enter")));
  1454.     if (FreeClimbVelocity.Length() < 0.01f || bHasTag)
  1455.         FreeClimbInput = FVector2D::ZeroVector;
  1456.     FreeClimbInput = FVector2D::Zero();
  1457.  
  1458.     bFreeClimbNotMoving = FreeClimbInput.Length() <= 0.0f;*/
  1459. }
  1460.  
  1461.  
  1462. void USDKenyaAnimInstance::UpdateSlideValues(const float DeltaSeconds)
  1463. {
  1464.     bIsSlidingDown = Proxy.Character->bIsSlidingDown;
  1465.     SlidingDownFalseBlendValue = 0.2f;
  1466.  
  1467.     SlideType = Proxy.Character->SlideType;
  1468.  
  1469.     if (!Proxy.CharacterMovement->IsFalling() || bIsDoubleJump)
  1470.         bWasSliding = false;
  1471.  
  1472.     const AActor* Floor = Proxy.CharacterMovement->CurrentFloor.HitResult.GetActor();
  1473.     if (Floor)
  1474.     {
  1475.         FloorActorTags = Floor->Tags;
  1476.         bWasSliding = bIsSlidingDown;
  1477.         SlidePitch = Proxy.CharacterMovement->CurrentFloor.HitResult.Normal.ToOrientationRotator().Pitch - 60.0f;
  1478.     }
  1479.     bIsSlidingOrSlideJumping = bIsSlidingDown || (bWasSliding && Velocity.Z > 0.0f);
  1480. }
  1481.  
  1482. void USDKenyaAnimInstance::UpdateStates()
  1483. {
  1484.     //0
  1485.     MovementMode_LastFrame = MovementMode;
  1486.     switch (Proxy.CharacterMovement->MovementMode)
  1487.     {
  1488.         case MOVE_None:
  1489.         case MOVE_Walking:
  1490.         case MOVE_NavWalking:
  1491.             MovementMode = EMM_MovementMode::OnGround;
  1492.             break;
  1493.         case MOVE_Falling:
  1494.             MovementMode = EMM_MovementMode::InAir;
  1495.             if (MovementMode_LastFrame == EMM_MovementMode::OnGround)
  1496.             {
  1497.                 PreviousGroundedGait = Gait;
  1498.             }
  1499.             break;
  1500.         case MOVE_Swimming:
  1501.         case MOVE_Flying:
  1502.         case MOVE_Custom:
  1503.         case MOVE_MAX:
  1504.         default:
  1505.             break;
  1506.     }
  1507.     //1
  1508.     RotationMode_LastFrame = RotationMode;
  1509.     Proxy.CharacterMovement->bOrientRotationToMovement ? RotationMode = EMM_RotationMode::OrientToMovement : RotationMode = EMM_RotationMode::Strafe;
  1510.     //2
  1511.     MovementState_LastFrame = MovementState;
  1512.     IsMovingUpdate();
  1513.     bIsMoving ? MovementState = EMM_MovementState::Moving : MovementState = EMM_MovementState::Idle;
  1514.     //3
  1515.     Gait_LastFrame = Gait;
  1516.     Gait = Proxy.Character->Gait;
  1517.    
  1518.    
  1519.     switch (Proxy.Character->Gait)//Weird
  1520.     {
  1521.     case EMM_Gait::Walk:
  1522.         Gait = EMM_Gait::Walk;
  1523.         break;
  1524.     case EMM_Gait::Run:
  1525.         Gait = EMM_Gait::Run;
  1526.         break;
  1527.     case EMM_Gait::Sprint:
  1528.         Gait = EMM_Gait::Sprint;
  1529.         break;
  1530.     }
  1531.     //4
  1532.     Stance_LastFrame = Stance;
  1533.     Proxy.CharacterMovement->IsCrouching() ? Stance = EMM_Stance::Crouch : Stance = EMM_Stance::Stand;
  1534. }
  1535.  
  1536.  
  1537. ///AnimGraph
  1538. #pragma region AnimGraph
  1539. float USDKenyaAnimInstance::Get_OffsetRootTranslationHalfLife() const
  1540. {
  1541.     switch (MovementState)
  1542.     {
  1543.     case EMM_MovementState::Idle:
  1544.         return 0.2;
  1545.     case EMM_MovementState::Moving:
  1546.         return 0.1;
  1547.     }
  1548.     return 0;
  1549. }
  1550.  
  1551. FFootPlacementInterpolationSettings USDKenyaAnimInstance::Get_FootPlacementInterpolationSettings() const
  1552. {
  1553.     return CurrentDatabaseTags.Contains(FName("Stops")) ? InterpolationSettings_Stops : InterpolationSettings_Default;
  1554. }
  1555.  
  1556. FFootPlacementPlantSettings USDKenyaAnimInstance::Get_FootPlacementPlantSettings() const
  1557. {
  1558.     return CurrentDatabaseTags.Contains(FName("Stops")) ? PlantSettings_Stops : PlantSettings_Default;
  1559. }
  1560. EOffsetRootBoneMode USDKenyaAnimInstance::Get_OffsetRootTranslationMode() const
  1561. {
  1562.     if ( IsSlotActive(FName("DefaultSlot")) )
  1563.     {
  1564.         return EOffsetRootBoneMode::Release;
  1565.     }
  1566.     switch (MovementMode)
  1567.     {
  1568.     case EMM_MovementMode::OnGround:
  1569.         return bIsMoving ? EOffsetRootBoneMode::Interpolate : EOffsetRootBoneMode::Release;
  1570.     case EMM_MovementMode::InAir:
  1571.         return EOffsetRootBoneMode::Release;
  1572.     }
  1573.     return EOffsetRootBoneMode::Accumulate;
  1574. }
  1575.  
  1576. EOffsetRootBoneMode USDKenyaAnimInstance::Get_OffsetRootRotationMode() const
  1577. {
  1578.     if (bAllowImmediateRotation or IsSlotActive(FName("DefaultSlot")) or bIsADS or bEnableBeamWalk)
  1579.     {
  1580.         return EOffsetRootBoneMode::Release;
  1581.     }
  1582.     if (RotationMode == EMM_RotationMode::Strafe)
  1583.     {
  1584.         FRotator Delta = Character->GetControlRotation() - RootTransform.Rotator();
  1585.         Delta.Normalize();
  1586.         return FMath::Abs(Delta.Yaw) > 25.0 ?  EOffsetRootBoneMode::Interpolate : EOffsetRootBoneMode::Release;
  1587.     }
  1588.     return EOffsetRootBoneMode::Accumulate;
  1589. }
  1590.  
  1591. bool USDKenyaAnimInstance::IsMoving() const
  1592. {
  1593.     constexpr float Threshold = 0.1f;
  1594.     return !Velocity.Equals( FVector::ZeroVector, Threshold) && !FutureVelocity.Equals( FVector::ZeroVector, Threshold);
  1595. }
  1596.  
  1597. float USDKenyaAnimInstance::Get_MMBlendTimeUpdate() const
  1598. {
  1599.     switch (MovementMode) {
  1600.         case EMM_MovementMode::OnGround:
  1601.             //if ((PreviousGroundedGait == EMM_Gait::Run or PreviousGroundedGait == EMM_Gait::Sprint) && Gait ==  EMM_Gait::Walk){return 0.4f;}
  1602.                 switch (MovementMode_LastFrame)
  1603.                 {
  1604.                     case EMM_MovementMode::OnGround:
  1605.                         return  0.4f;
  1606.                     case EMM_MovementMode::InAir:
  1607.                         return 0.2f;
  1608.                 }
  1609.             break;
  1610.         case EMM_MovementMode::InAir:
  1611.             if (Velocity.Z > 100.0f)
  1612.             {
  1613.                 return 0.15f;
  1614.             }
  1615.             return 0.5f;
  1616.     }
  1617.     return 0;
  1618. }
  1619.  
  1620. float USDKenyaAnimInstance::Get_MMNotifyRecencyTimeoutUpdate() const
  1621. {
  1622.     switch (Gait)
  1623.     {
  1624.     case EMM_Gait::Walk:
  1625.         return  0.2f;
  1626.     case EMM_Gait::Run:
  1627.         return 0.2f;
  1628.     case EMM_Gait::Sprint:
  1629.         return 0.16f;
  1630.     }
  1631.     return 0;
  1632. }
  1633.  
  1634. EPoseSearchInterruptMode USDKenyaAnimInstance::Get_MMInterrupt() const
  1635. {
  1636.  
  1637.     return MovementMode != MovementMode_LastFrame or ( (MovementState != MovementState_LastFrame or Gait != Gait_LastFrame or Stance != EMM_Stance::Stand or MotionMatchingDB_LastFrame != MotionMatchingDB) && MovementMode == EMM_MovementMode::OnGround or bChangeMotionMatchingDBGet_MMInterruptNow )
  1638.     ? EPoseSearchInterruptMode::InterruptOnDatabaseChange : EPoseSearchInterruptMode::DoNotInterrupt;
  1639. }
  1640.  
  1641. void USDKenyaAnimInstance::Update_MotionMatchingDBS(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
  1642. {
  1643.     EAnimNodeReferenceConversionResult Result{};
  1644.     const FMotionMatchingAnimNodeReference MM = UMotionMatchingAnimNodeLibrary::ConvertToMotionMatchingNode(Node, Result);
  1645.     //if (Result == EAnimNodeReferenceConversionResult::Failed) return; Unsafe
  1646.     //UPoseSearchDatabase* DB = Cast<UPoseSearchDatabase>(UChooserFunctionLibrary::EvaluateChooser(this, LocomotionTable, UPoseSearchDatabase::StaticClass())); FOR SIngle Database
  1647.     TArray<UObject*> RawResults = UChooserFunctionLibrary::EvaluateChooserMulti(this, CurrentCHT, UPoseSearchDatabase::StaticClass());
  1648.     TArray<UPoseSearchDatabase*> Databases;
  1649.     Databases.Reserve(RawResults.Num());
  1650.     for (UObject* Obj : RawResults)
  1651.     {
  1652.         Databases.Add(Cast<UPoseSearchDatabase>(Obj)); //No safety check for performance reasons
  1653.     }
  1654.     UMotionMatchingAnimNodeLibrary::SetDatabasesToSearch(MM, Databases, Get_MMInterrupt());
  1655.     //LOG_THREAD_LOCATION(0.01,"Update_MotionMatchingDBS");
  1656.     //Update other AnimGraph variables
  1657.     IsMovingUpdate();
  1658. }
  1659.  
  1660. void USDKenyaAnimInstance::Update_MotionMatchingPostSelection(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
  1661. {
  1662.     if (!CurrentSelectedDatabase.Get() ) return;
  1663.     EAnimNodeReferenceConversionResult Result{};
  1664.     const FMotionMatchingAnimNodeReference MM = UMotionMatchingAnimNodeLibrary::ConvertToMotionMatchingNode(Node, Result);
  1665.     //if (Result == EAnimNodeReferenceConversionResult::Failed) return;unsafe for perf
  1666.     FPoseSearchBlueprintResult OutResult;
  1667.     bool bIsValidResult;
  1668.     UMotionMatchingAnimNodeLibrary::GetMotionMatchingSearchResult(MM, OutResult, bIsValidResult);
  1669.     CurrentSelectedDatabase = OutResult.SelectedDatabase;
  1670. }
  1671.  
  1672. FVector2D USDKenyaAnimInstance::Get_LeanAmount() const
  1673. {
  1674.     const float LeanMultiplier = FMath::GetMappedRangeValueClamped(FVector2D(150.0f, 350.0f), FVector2D(0.5f, 1.0f), Speed2D);
  1675.     // Apply to X component (forward/backward acceleration)
  1676.     return FVector2D( CalculateRelativeAccelerationAmount().X * LeanMultiplier, 0.0f);
  1677. }
  1678.  
  1679. FVector USDKenyaAnimInstance::CalculateRelativeAccelerationAmount() const
  1680. {
  1681.     if (!CharacterMovement) return FVector::Zero();
  1682.     if ( CharacterMovement->MaxAcceleration > 0.0f && CharacterMovement->GetMaxBrakingDeceleration() > 0.0f )
  1683.     {
  1684.         if (  FVector::DotProduct(Velocity, Acceleration) > 0.0f )
  1685.         {
  1686.             return  CharacterTransform.Rotator().UnrotateVector(VelocityAcceleration.GetClampedToMaxSize(CharacterMovement->GetMaxAcceleration()) / CharacterMovement->MaxAcceleration);
  1687.         }
  1688.         const FVector A = VelocityAcceleration.GetClampedToMaxSize(CharacterMovement->MaxAcceleration) / CharacterMovement->GetMaxAcceleration();
  1689.         return  CharacterTransform.Rotator().UnrotateVector(A);
  1690.     }
  1691.     return FVector(0.0f);
  1692. }
  1693. #pragma endregion;
  1694.  
  1695.  
  1696. #pragma region Delegates
  1697.  
  1698. void USDKenyaAnimInstance::OnLandingEventReceived(FGameplayEventData Payload)
  1699. {
  1700.     bLocomotionLanded = true;
  1701.     bIsDoubleJump = false;
  1702.     bIsAirDash = false;
  1703.  
  1704.     //const FHitResult TargetDataHit = UAbilitySystemBlueprintLibrary::GetHitResultFromTargetData(Payload.TargetData, 0); todo: Comment by Vila Carlos: Please don't do any BlueprintLibrary calls as it involves severe overhead
  1705.     const FHitResult TargetDataHit = [&]() -> FHitResult
  1706.     {
  1707.         const auto& TD = Payload.TargetData;
  1708.         if (TD.Data.IsValidIndex(0))
  1709.         {
  1710.             if (FGameplayAbilityTargetData* DataPtr = TD.Data[0].Get())
  1711.             {
  1712.                 if (const FHitResult* HitPtr = DataPtr->GetHitResult())
  1713.                 {
  1714.                     return *HitPtr;
  1715.                 }
  1716.             }
  1717.         }
  1718.         // fallback if there was no valid hit
  1719.         return FHitResult();
  1720.     }();
  1721.     //LandVelocity = TargetDataHit.Normal;
  1722.     LandVelocity = CharacterMovement->Velocity;
  1723.     const AActor* Floor = TargetDataHit.GetActor();
  1724.     if (Floor)
  1725.     {
  1726.         FloorActorTags = Floor->Tags;
  1727.     }
  1728.     //LandVelocity = UAbilitySystemBlueprintLibrary::GetHitResultFromTargetData(Payload.TargetData, 0).Normal;
  1729.     FTimerManager& TimerManager = Character->CachedWorld->GetTimerManager();
  1730.     TimerManager.ClearTimer(LandingResetTimerHandle);
  1731.     TimerManager.SetTimer(LandingResetTimerHandle,
  1732.     FTimerDelegate::CreateWeakLambda(this, [this]()
  1733.     {
  1734.         bLocomotionLanded = false;
  1735.         bLandFromDoubleJump = false;
  1736.         bLandFromAirDash = false;
  1737.     }),0.2f, false );
  1738.     if (!JustLandedSprintingDoubleJump())
  1739.     {
  1740.         JustLandedHeavyUpdate();
  1741.         if (bJustLandedHeavy) {
  1742.  
  1743.             if (CanRunOnce())
  1744.             {
  1745.                 FOnMontageBlendingOutStarted BlendOutDelegate;
  1746.                 BlendOutDelegate.BindUObject(this, &ThisClass::HardLandingOnRollMontageBlendOut);
  1747.                 Montage_Play(LandRollMontage, 1.0f);
  1748.                 Montage_SetBlendingOutDelegate(BlendOutDelegate, LandRollMontage);
  1749.             }
  1750.         }
  1751.     }
  1752. }
  1753. void USDKenyaAnimInstance::TaskTestTiming_Implementation()
  1754. {
  1755. }
  1756.  
  1757. void USDKenyaAnimInstance::HardLandingOnRollMontageBlendOut(UAnimMontage* Montage, bool bInterrupted)
  1758. {
  1759.     CharacterMovement->StopMovementImmediately();
  1760.     bHasRun = false;
  1761. }
  1762.  
  1763.  
  1764.  
  1765. bool USDKenyaAnimInstance::JustLandedSprintingDoubleJump() const
  1766. {
  1767.     return bLandFromDoubleJump && bLocomotionLanded && (PreviousGroundedGait == EMM_Gait::Sprint or Gait == EMM_Gait::Sprint);
  1768. }
  1769.  
  1770. void USDKenyaAnimInstance::ChangeMMInterruptToTrue()
  1771. {
  1772.     bChangeMotionMatchingDBGet_MMInterruptNow=true;
  1773.  
  1774.     GetWorld()->GetTimerManager().SetTimer(TimerHandleInterruptToTrue, this, &USDKenyaAnimInstance::ChangeMMInterruptToTrueNow, 0.1f, false);
  1775.  
  1776. }
  1777.  
  1778. void USDKenyaAnimInstance::ChangeMMInterruptToTrueNow()
  1779. {
  1780.     bChangeMotionMatchingDBGet_MMInterruptNow=false;
  1781. }
  1782.  
  1783. void USDKenyaAnimInstance::CoversystemMovingCheckUpdate()
  1784. {
  1785.     if LIKELY(CharacterMovement->IsValidLowLevelFast())
  1786.     {
  1787.         bIsMovingNow = CharacterMovement->Velocity.Length()>0;
  1788.  
  1789.     }
  1790. }
  1791.  
  1792. void USDKenyaAnimInstance::StartTimerCover()
  1793. {
  1794.     float TimerDelay = 0.003f; // Set timer delay to 1 second
  1795.     GetWorld()->GetTimerManager().SetTimer(TimerHandleCoverStart, this, &USDKenyaAnimInstance::CoversystemMovingCheckUpdate, TimerDelay, true);
  1796.     GEngine->AddOnScreenDebugMessage(-1, 2.f,FColor::Blue, TEXT("-----move tiemr start-----"));
  1797.  
  1798. }
  1799.  
  1800. void USDKenyaAnimInstance::StopTimerCover()
  1801. {
  1802.     GetWorld()->GetTimerManager().ClearTimer(TimerHandleCoverStart);
  1803.  
  1804. }
  1805.  
  1806. void USDKenyaAnimInstance::IdleAimOffsetYawPitchUpdate(float DeltaTime)
  1807. {
  1808.     if (OverlayState==EOverlayState::Unarmed&&MovementState==EMM_MovementState::Idle&&MovementMode==EMM_MovementMode::OnGround&&Speed2D<20&&bJustLandedLight==false&&bJustLandedHeavy==false)
  1809.     {
  1810.         UseIdleAimOffset=true;
  1811.     }
  1812.     else
  1813.     {
  1814.         UseIdleAimOffset=false;
  1815.         return;
  1816.     }
  1817.  
  1818.     const float YawCacheMovement = Character->GetCapsuleComponent()->GetComponentRotation().Yaw;
  1819.     const float YawCache = Character->GetControlRotation().Yaw;
  1820.     float YawOriginal = YawCache-YawCacheMovement;
  1821.     float PitchOriginal = FRotator::NormalizeAxis(TryGetPawnOwner()->GetBaseAimRotation().Pitch);
  1822.    
  1823.    
  1824.  
  1825.     float YawSpeedMultiplier = 2.5f;
  1826.     float PitchSpeedMultiplier = 2.5f;
  1827.     YawOriginal = (YawOriginal > 180.0f) ? (YawOriginal - 360.0f) : YawOriginal;
  1828.     if (FMath::Abs(YawOriginal)>130.0f)
  1829.     {
  1830.         YawOriginal=0;
  1831.         PitchOriginal = 0;
  1832.         YawSpeedMultiplier=1.5f;
  1833.         PitchSpeedMultiplier=1.5f;
  1834.        
  1835.     }
  1836.    
  1837.     YawOriginal = FMath::Clamp(YawOriginal, -90.0f, 90.0f);
  1838.     PitchOriginal = FMath::Clamp(PitchOriginal, -70.0f, 70.0f);
  1839.  
  1840.  
  1841.  
  1842.     IdleAimOffsetYaw=FMath::Lerp(IdleAimOffsetYaw, YawOriginal, DeltaTime*YawSpeedMultiplier);
  1843.     IdleAimOffsetPitch=FMath::Lerp(IdleAimOffsetPitch, PitchOriginal, DeltaTime*PitchSpeedMultiplier);
  1844.  
  1845. }
  1846.  
  1847. void USDKenyaAnimInstance::ShockFirePawPitchUpdate()
  1848. {
  1849.     //for pitch
  1850.  
  1851.     if UNLIKELY(!Character)
  1852.     {
  1853.         return;
  1854.     }
  1855.  
  1856.     float PitchCache = Character->GetControlRotation().Pitch;
  1857.  
  1858.     constexpr float TimeMultiplier = 4.0f;
  1859.     PitchCache = (PitchCache > 180.0f) ? (PitchCache - 360.0f) : PitchCache;
  1860.     ShockPitch=FMath::Lerp(ShockPitch, PitchCache, 0.001f * TimeMultiplier);
  1861.    
  1862.     //FQuat DeltaRotation = EndRotation.Inverse() * StartRotation;
  1863.     const FQuat StartRotation = Character->GetCapsuleComponent()->GetComponentRotation().Quaternion(); // Initial rotation (e.g., the start state)
  1864.     const FQuat EndRotation = Character->GetControlRotation().Quaternion(); // End rotation (90 degrees on the Z axis)
  1865.  
  1866.     //FQuat DeltaRotation = EndRotation.Inverse() * StartRotation;
  1867.     const FQuat DeltaRotation = StartRotation.Inverse() * EndRotation;
  1868.     //yawOriginal=delta.Yaw;
  1869.     float YawOriginal = DeltaRotation.Rotator().Yaw;
  1870.    
  1871.     YawOriginal = (YawOriginal > 180.0f) ? (YawOriginal - 360.0f) : YawOriginal;
  1872.     YawOriginal = FMath::Clamp(YawOriginal, -150.0f, 150.0f);;
  1873.  
  1874.     ShockYaw = FMath::Lerp(ShockYaw, YawOriginal, 0.001f*TimeMultiplier);
  1875.    
  1876.     ///
  1877.     ///Aim Offset
  1878.     if (bIsSlidingDown) {
  1879.         // Use right hand when sliding and turning towards left (when right hand is up)
  1880.         ShockFireUseRightHand = (InputVector.X < -0.5f);
  1881.     }
  1882.     else if (ShockYaw > 0 != ShockFireUseRightHand && !psycheScanNoUseRightHandNow)
  1883.     {
  1884.         ShockFireUseRightHand=ShockYaw>0;
  1885.  
  1886.         if (bUseShockFire)
  1887.         {
  1888.             Character->OverlayStateN=EOverlayState::Unarmed;
  1889.  
  1890.             // Set the timer to call TimerFunction after 0.01 second
  1891.             //GetWorld()->GetTimerManager().SetTimer(TimerHandleShockAOScan, this, &USDKenyaAnimInstance::ShockFireAOchangeStateScanBack, 0.01f, false);
  1892.  
  1893.         }
  1894.     }
  1895.    
  1896.     /*if (psycheScanNoUseRightHandNow)
  1897.     {
  1898.         Character->OverlayStateN=EOverlayState::Unarmed;
  1899.     }*/
  1900.  
  1901.  
  1902. }
  1903.  
  1904. void USDKenyaAnimInstance::ShockFireAOchangeStateScanBack()
  1905. {
  1906.     Character->OverlayStateN=EOverlayState::Scan;
  1907. }
  1908.  
  1909. void USDKenyaAnimInstance::SetStateShockFireAimOfsett(bool start)
  1910. {
  1911.     if (bUseShockFire==start)
  1912.     {
  1913.         return;
  1914.     }
  1915.     bUseShockFire=start;
  1916.     if (start)
  1917.     {
  1918.         GetWorld()->GetTimerManager().SetTimer(TimerHandleStateShockFireAimOfsett, this, &USDKenyaAnimInstance::ShockFirePawPitchUpdate, 0.001f, true);
  1919.  
  1920.     }
  1921.     else
  1922.     {
  1923.         GetWorld()->GetTimerManager().ClearTimer(TimerHandleStateShockFireAimOfsett);
  1924.     }
  1925. }
  1926.  
  1927. void USDKenyaAnimInstance::idleTurnInplaceTick()
  1928. {
  1929.     FRotator RMesh = GetSkelMeshComponent()->GetSocketRotation(FName("rootSocket"));
  1930.  
  1931.     FQuat QuatA = FQuat(RMesh);
  1932.     FQuat QuatB = FQuat(TryGetPawnOwner()->GetActorRotation());
  1933.  
  1934.     // Calculate the difference (delta) as a quaternion
  1935.     FQuat DeltaQuat = QuatA.Inverse() * QuatB;
  1936.  
  1937.     // Convert the delta quaternion back to a rotator
  1938.     FRotator DeltaRotation = DeltaQuat.Rotator();
  1939.  
  1940.  
  1941.     if (FMath::Abs(DeltaRotation.Yaw) > 45&&Speed2D<100)
  1942.     {
  1943.         idleTurnInplace = true;
  1944.     }
  1945.     else
  1946.     {
  1947.         idleTurnInplace = false;
  1948.     }
  1949. }
  1950.  
  1951. void USDKenyaAnimInstance::StartMinigunShooting(bool startShootingAimOffset)
  1952. {
  1953.     bMinigunActive=startShootingAimOffset;
  1954.     if (startShootingAimOffset)
  1955.     {
  1956.         GetWorld()->GetTimerManager().SetTimer(MyTimerHandle, this, &USDKenyaAnimInstance::PlayerPitchUpdate, 0.033f, true);
  1957.  
  1958.     }
  1959.     else
  1960.     {
  1961.         GetWorld()->GetTimerManager().ClearTimer(MyTimerHandle);
  1962.  
  1963.     }
  1964. }
  1965.  
  1966. void USDKenyaAnimInstance::PlayerPitchUpdate()
  1967. {
  1968.     //GEngine->AddOnScreenDebugMessage(-1, 2.f,FColor::Blue, TEXT("-----MOVE FORWARD Activeeeeeeee -----"));
  1969.  
  1970.     pitchMinigun=TryGetPawnOwner()->GetControlRotation().Pitch;
  1971.  
  1972.     if (pitchMinigun>180.0f)
  1973.     {
  1974.         pitchMinigun-=360.0f;
  1975.     }
  1976.  
  1977.     pitchMinigun+=15.0f;
  1978. }
  1979.  
  1980. void USDKenyaAnimInstance::SetRootYawOffset1(float InRootYawOffset)
  1981. {
  1982.  
  1983.     RootYawOffset1=FMath::ClampAngle(UKismetMathLibrary::NormalizeAxis(InRootYawOffset),RootYawOffsetAngleClamp.X,RootYawOffsetAngleClamp.Y);
  1984. }
  1985.  
  1986.  
  1987. void USDKenyaAnimInstance::ProcessTurnYawCurve()
  1988. {
  1989.     PreviousTurnYawCurveValue=TurnYawCurveValue;
  1990.  
  1991.    
  1992.  
  1993.     if (FMath::IsNearlyEqual(GetCurveValue(TEXT("TNT_TurnYawWeight")),0.0f, 0.0001f))
  1994.     {
  1995.         TurnYawCurveValue=0;
  1996.         PreviousTurnYawCurveValue=0;
  1997.     }
  1998.     else
  1999.     {
  2000.         TurnYawCurveValue=GetCurveValue(TEXT("TNT_TurnYaw"))/GetCurveValue(TEXT("TNT_TurnYawWeight"));
  2001.         if (PreviousTurnYawCurveValue!=0)
  2002.         {
  2003.             SetRootYawOffset1(RootYawOffset1-(TurnYawCurveValue-PreviousTurnYawCurveValue));
  2004.         }
  2005.     }
  2006.     PreviousTurnYawCurveValue=0;
  2007. }
  2008.  
  2009. void USDKenyaAnimInstance::UpdateRootYawOffset(float InDeltaTime)
  2010. {
  2011.     SetRootYawOffset1(RootYawOffset1-YawDeltaSinceLastUpdate2);
  2012.     IsFirstUpdate=false;
  2013. }
  2014.  
  2015. void USDKenyaAnimInstance::UpdateIdleState(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
  2016. {
  2017.     //EAnimNodeReferenceConversionResult
  2018.     EAnimNodeReferenceConversionResult ConvR1;
  2019.     FAnimationStateResultReference State1;
  2020.     UAnimationStateMachineLibrary::ConvertToAnimationStateResult(Node,State1,ConvR1);
  2021.     if (UAnimationStateMachineLibrary::IsStateBlendingOut(Context,State1))
  2022.     {
  2023.         TurnYawCurveValue=0;
  2024.     }
  2025.     {
  2026.         ProcessTurnYawCurve();
  2027.     }
  2028. }
  2029.  
  2030. void USDKenyaAnimInstance::UpdateRotationData()
  2031. {
  2032.     YawDeltaSinceLastUpdate2=GetOwningActor()->GetActorRotation().Yaw-WorldRotation.Yaw;
  2033.     WorldRotation=GetOwningActor()->GetActorRotation();
  2034.     if (IsFirstUpdate)
  2035.     {
  2036.         YawDeltaSinceLastUpdate2=0;
  2037.     }
  2038. }
  2039.  
  2040. void USDKenyaAnimInstance::SetupTurnInPlaceAnim(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
  2041. {
  2042.    
  2043.     TurnInPlaceAnimTime=0;
  2044.     EAnimNodeReferenceConversionResult Result1;
  2045.     USequenceEvaluatorLibrary::SetExplicitTime(USequenceEvaluatorLibrary::ConvertToSequenceEvaluator(Node,Result1),0.0f);
  2046.  
  2047.    
  2048. }
  2049.  
  2050. UAnimSequence*  USDKenyaAnimInstance::SelectTurnInPlaceAnimation(float Direction)
  2051. {
  2052.     if (Direction>0)
  2053.     {
  2054.         return  TurninPlaceRight;
  2055.     }
  2056.     return TurninPlaceLeft;
  2057. }
  2058.  
  2059. void USDKenyaAnimInstance::UpdateTurnInPlaceAnim(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
  2060. {
  2061.     EAnimNodeReferenceConversionResult Result1;
  2062.     USequenceEvaluatorLibrary::SetSequenceWithInertialBlending(Context,USequenceEvaluatorLibrary::ConvertToSequenceEvaluator(Node,Result1),SelectTurnInPlaceAnimation(TurninPlaceRotationDirection),0.2f);
  2063.  
  2064.     TurnInPlaceAnimTime=UAnimExecutionContextLibrary::GetDeltaTime(Context)+TurnInPlaceAnimTime;
  2065.     USequenceEvaluatorLibrary::SetExplicitTime(USequenceEvaluatorLibrary::ConvertToSequenceEvaluator(Node,Result1),TurnInPlaceAnimTime);
  2066.    
  2067. }
  2068.  
  2069. void USDKenyaAnimInstance::SetUpTurnInPlaceRotationState(const FAnimUpdateContext& Context,
  2070.     const FAnimNodeReference& Node)
  2071. {
  2072.     TurninPlaceRotationDirection=FMath::Sign(RootYawOffset1)*-1.0f;
  2073. }
  2074.  
  2075. /*void USDKenyaAnimInstance::SetUpTurnInPlaceRecoveryState(const FAnimUpdateContext& Context,
  2076.     const FAnimNodeReference& Node)
  2077. {
  2078. }*/
  2079.  
  2080. void USDKenyaAnimInstance::UpdateTurnInPlaceRecoveryAnim(const FAnimUpdateContext& Context,
  2081.     const FAnimNodeReference& Node)
  2082. {
  2083.     EAnimNodeReferenceConversionResult Result1;
  2084.     USequencePlayerLibrary::SetSequenceWithInertialBlending(Context,USequencePlayerLibrary::ConvertToSequencePlayer(Node,Result1),SelectTurnInPlaceAnimation(TurninPlaceRotationDirection),0.2f);
  2085. }
  2086.  
  2087. void USDKenyaAnimInstance::OnStateEntry(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
  2088. {
  2089.     TurnInPlaceAnimTime=0;
  2090.     TurninPlaceRotationDirection=FMath::Sign(RootYawOffset1)*-1.0f;
  2091.    
  2092. }
  2093.  
  2094. void USDKenyaAnimInstance::OnStateFullyBlendedIn_0(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
  2095. {
  2096.     TurnInPlaceAnimTime=0;
  2097. }
  2098.  
  2099. /*void USDKenyaAnimInstance::OnStateFullyBlendedOut(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
  2100. {
  2101. }*/
  2102.  
  2103. void USDKenyaAnimInstance::OnFreeClimbBecomeRelevant(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
  2104. {
  2105.     bUsedClimbDashBackup = !bUsedClimbDashBackup;
  2106. }
  2107. /*
  2108. bool USDKenyaAnimInstance::JustLanded_Heavy() const
  2109. {
  2110.     return bLocomotionLanded && FMath::Abs(LandVelocity.Z) >= FMath::Abs(HeavyLandSpeedThreshold);
  2111. }
  2112.  
  2113. bool USDKenyaAnimInstance::JustLanded_Light() const
  2114. {
  2115.     return bLocomotionLanded && FMath::Abs(LandVelocity.Z) < FMath::Abs(HeavyLandSpeedThreshold);
  2116. }
  2117. */
  2118. bool USDKenyaAnimInstance::IsPivoting() const
  2119. {
  2120.     //if (FutureVelocity.IsNearlyZero() || Velocity.IsNearlyZero()) return false;
  2121.     //return FMath::Abs( UKismetMathLibrary::NormalizedDeltaRotator(FutureVelocity.ToOrientationRotator(), Velocity.ToOrientationRotator()).Yaw ) >= (RotationMode == EMM_RotationMode::OrientToMovement ? 60.f : 40.f);
  2122.     FRotator Delta = FutureVelocity.ToOrientationRotator() - Velocity.ToOrientationRotator();
  2123.     Delta.Normalize();
  2124.     return FMath::Abs( Delta.Yaw ) >= (RotationMode == EMM_RotationMode::OrientToMovement ? 60.f : 40.f);
  2125.    
  2126. }
  2127.  
  2128. bool USDKenyaAnimInstance::IsStarting()
  2129. {
  2130.     IsMovingUpdate();
  2131.     return bIsMoving && (FutureVelocity.Size2D() >= Velocity.Size2D()+100) && !CurrentDatabaseTags.Contains(FName("Pivots"));
  2132. }
  2133.  
  2134. void USDKenyaAnimInstance::OnJumpDoubleTaskReceived(FGameplayEventData Payload)
  2135. {
  2136.     //GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, TEXT("!"));
  2137.     const FVector LastInputVector = CharacterMovement->GetLastInputVector();
  2138.     if (!LastInputVector.IsNearlyZero(0.0001))
  2139.     {
  2140.         CharacterMovement->bOrientRotationToMovement = false;
  2141.         Character->SetActorRotation(LastInputVector.ToOrientationRotator());
  2142.     }  
  2143.     bIsDoubleJump = true;
  2144.     bLandFromDoubleJump = true;
  2145.     bIsDoubleJumpStart = true;
  2146.     FTimerManager& TimerManager = Character->CachedWorld->GetTimerManager();
  2147.     TimerManager.ClearTimer(DoubleJumpTimerHandle);
  2148.     TimerManager.SetTimer(DoubleJumpTimerHandle,
  2149.     FTimerDelegate::CreateWeakLambda(this, [this]()
  2150.     {
  2151.         bIsDoubleJumpStart = false;
  2152.         CharacterMovement->bOrientRotationToMovement = true;
  2153.     }),0.3f, false );
  2154. }
  2155.  
  2156. void USDKenyaAnimInstance::OnAirDashTaskReceived(FGameplayEventData Payload)
  2157. {
  2158.     bIsAirDash = true;
  2159.     bLandFromAirDash = true;
  2160. }
  2161.  
  2162. void USDKenyaAnimInstance::OnClimbBeginTaskReceived(FGameplayEventData Payload)
  2163. {
  2164.     /*Todo Implement Interface for this function to work
  2165.      *if (Payload.Target->GetClass()->ImplementsInterface(UBPI_ClimbV2::StaticClass()))
  2166.     if (TargetActor && TargetActor->GetClass()->ImplementsInterface(UBPI_ClimbV2::StaticClass()))
  2167.     {
  2168.         EClimbState ClimbType = EClimbState::Default;
  2169.         IBPI_ClimbV2::Execute_BPI_GetClimbType(TargetActor, ClimbType);
  2170.         ClimbState = ClimbType;
  2171.         OnClimbBegin();
  2172.         GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Green, TEXT("GOOD"));
  2173.     }*/
  2174.     /*AActor* TargetActor = const_cast<AActor*>(Payload.Target.Get());
  2175.     if (TargetActor && TargetActor->GetClass()->ImplementsInterface(UBPI_ClimbV2::StaticClass()))
  2176.     {
  2177.         EClimbState ClimbType = EClimbState::Default;
  2178.         IBPI_ClimbV2::Execute_BPI_GetClimbType(TargetActor, ClimbType);
  2179.         ClimbState = ClimbType;
  2180.         OnClimbBegin();
  2181.         GEngine->AddOnScreenDebugMessage(-1,10.0f, FColor::Green,TEXT("GOOD"));
  2182.     } else
  2183.     {
  2184.         GEngine->AddOnScreenDebugMessage(-1,10.0f, FColor::Green,TEXT("CONST CAST ISSUE"));
  2185.     }*/
  2186. }
  2187. void USDKenyaAnimInstance::OnClimbBegin()
  2188. {
  2189.     bIsClimbing = true;
  2190.     Character->bIsClimbing = true;
  2191. }
  2192.  
  2193.  
  2194. void USDKenyaAnimInstance::OnClimbReachFinishedTaskReceived(FGameplayEventData Payload)
  2195. {
  2196.     bIsClimbReaching = false;
  2197. }
  2198.  
  2199.  
  2200. void USDKenyaAnimInstance::OnClimbTransitionTaskReceived(FGameplayEventData Payload)
  2201. {
  2202.     bIsClimbTransitioning = true;
  2203.     bIsClimbReaching = false;
  2204.     FTimerManager& TimerManager = Character->CachedWorld->GetTimerManager();
  2205.     TimerManager.ClearTimer(ClimbTransitionTimerHandle);
  2206.     TimerManager.SetTimer(ClimbTransitionTimerHandle,
  2207.     FTimerDelegate::CreateWeakLambda(this, [this]()
  2208.     {
  2209.         bIsClimbTransitioning = false;
  2210.     }),1.0f, false );
  2211. }
  2212.  
  2213. void USDKenyaAnimInstance::OnPerchTurnEndedTaskReceived(FGameplayEventData Payload)
  2214. {
  2215.     if (InputMovementSpeed != FVector2D::ZeroVector)
  2216.     {
  2217.         bIsPerchTurnEnded = true;
  2218.         FTimerManager& TimerManager = Character->CachedWorld->GetTimerManager();
  2219.         TimerManager.ClearTimer(PerchTurnEndedTimerHandle);
  2220.         TimerManager.SetTimer(PerchTurnEndedTimerHandle,
  2221.         FTimerDelegate::CreateWeakLambda(this, [this]()
  2222.         {
  2223.             bIsPerchTurnEnded = false;
  2224.         }),1.0f, false);
  2225.     } else
  2226.     {
  2227.         Montage_Stop(0.2, GetCurrentActiveMontage());
  2228.         bIsPerchTurnEnded = false;
  2229.     }
  2230. }
  2231.  
  2232. void USDKenyaAnimInstance::OnStandBeginTaskReceived(FGameplayEventData Payload)
  2233. {
  2234.     bIsClimbing = false;
  2235.     Character->bIsClimbing = false;
  2236. }
  2237.  
  2238. void USDKenyaAnimInstance::OnFreeClimbJumpTagAddedTaskReceived()
  2239. {
  2240.     bFreeClimbJumpOff = true;
  2241. }
  2242.  
  2243. void USDKenyaAnimInstance::OnFreeClimbJumpTagRemovedTaskReceived()
  2244. {
  2245.     bFreeClimbJumpOff = false;
  2246. }
  2247. #pragma endregion
  2248.  
  2249.  
  2250. #pragma region Utilities
  2251.  
  2252.  
  2253. #pragma endregion
  2254.  
  2255. float USDKenyaAnimInstance::Get_RightLean()
  2256. {
  2257.     if (!Character  or Speed2D < KENYA_WALK_SPEED*.4 or MovementState == EMM_MovementState::Idle) return 0.f;
  2258.  
  2259.     if (CheckCombatStance())
  2260.     {
  2261.         switch (Gait) {
  2262.         case EMM_Gait::Walk:
  2263.             CurrentLeanBlendMontage = WalkLeanBlendMontage;
  2264.             break;
  2265.         case EMM_Gait::Run:
  2266.             CurrentLeanBlendMontage = RunLeanBlendMontage;
  2267.             break;
  2268.         case EMM_Gait::Sprint:
  2269.             CurrentLeanBlendMontage = SprintLeanBlendMontage;
  2270.             break;
  2271.         }
  2272.     } else
  2273.     {
  2274.         switch (Gait) {
  2275.         case EMM_Gait::Walk:
  2276.             CurrentLeanBlendMontage = CombatWalkLeanBlendMontage;
  2277.             break;
  2278.         case EMM_Gait::Run:
  2279.             CurrentLeanBlendMontage = CombatRunLeanBlendMontage;
  2280.             break;
  2281.         case EMM_Gait::Sprint:
  2282.             CurrentLeanBlendMontage = CombatSprintLeanBlendMontage;
  2283.             break;
  2284.         }
  2285.     }
  2286.     return CalculateRelativeAccelerationAmount().Y*UKismetMathLibrary::MapRangeClamped(Speed2D,200.0f,500.0f,0.5f,1.0f);
  2287.  
  2288.     //return Character->TurnRate*BlendSpaceAmount;
  2289.     /*const float DeltaSeconds = GetWorld()->GetDeltaSeconds();
  2290.     if(Gait==EMM_Gait::Walk){
  2291.         FVector2d S(Velocity.X,Velocity.Y);
  2292.         LeanTimer = FMath::Sign(Velocity.Y)!=FMath::Sign(VelocityLastFrame.Y) ?
  2293.             MaxLeanDuration : FMath::Max(0.f, LeanTimer-DeltaSeconds);
  2294.  
  2295.         return (S.SizeSquared()>KINDA_SMALL_NUMBER ?
  2296.             (S.Normalize(), S.Y) : 0.f)
  2297.                 * (MaxLeanDuration>0.f ? LeanTimer/MaxLeanDuration : 0.f);
  2298.     }*/
  2299.     /*if ( Gait == EMM_Gait::Walk )
  2300.     {
  2301.         FVector2d Speed = FVector2d(Velocity.X, Velocity.Y);
  2302.         Speed.Normalize();
  2303.         return Speed.Y;
  2304.     }*/
  2305.    
  2306.         /*FVector2d Speed = FVector2d(Velocity.X, Velocity.Y);
  2307.             Speed.Normalize();*/
  2308.         //GEngine->AddOnScreenDebugMessage(-1,5.0f,FColor::Yellow,FString::Printf(TEXT("TurnRate: %f"), Proxy.Character->TurnRate*2.5));
  2309. }
  2310.  
  2311. //Blend Stack
  2312. void USDKenyaAnimInstance::UpdateBlendStack(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
  2313. {
  2314.     AnimTime = UBlendStackAnimNodeLibrary::GetCurrentBlendStackAnimAssetTime(Node);
  2315.     AnimAsset = UBlendStackAnimNodeLibrary::GetCurrentBlendStackAnimAsset(Node);
  2316.     const UAnimSequence* NewAnimSequence = Cast<UAnimSequence>(AnimAsset);
  2317.     //if (!NewAnimSequence) return;Unsafe
  2318.     UAnimationWarpingLibrary::GetCurveValueFromAnimation(NewAnimSequence, "Enable_OrientationWarping", AnimTime, OrientationAlpha);
  2319.  
  2320.     //Update Rest of Values
  2321.     IsTurningInPlaceUpdate();
  2322.     DesiredFacingUpdate();
  2323.     EnableSteeringUpdate();
  2324.     OrientationWarpingWarpingSpaceUpdate();
  2325. }
  2326.  
  2327. bool USDKenyaAnimInstance::CheckCombatStance() const
  2328. {
  2329.     if (!Character) return false;
  2330.  
  2331.     return Character->GetAbilitySystemComponent()->HasMatchingGameplayTag(FGameplayTag::RequestGameplayTag(FName("Status.Combat")));
  2332. }
  2333.  
  2334. void USDKenyaAnimInstance::CheckCombatStanceV()
  2335. {
  2336.     bCombatStance = Character->GetAbilitySystemComponent()->HasMatchingGameplayTag(FGameplayTag::RequestGameplayTag(FName("Status.Combat")));
  2337. }
  2338.  
  2339. void USDKenyaAnimInstance::UpdateOffSetRootNode(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
  2340. {
  2341.     UpdateRootBoneNode = Node;
  2342. }
  2343.  
  2344. void USDKenyaAnimInstance::OnZiplineInitialUpdate(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
  2345. {
  2346.     bZiplineJumpAnimEnd = false;
  2347. }
  2348.  
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment