Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HEADER]
- #pragma once
- #include "CoreMinimal.h"
- #include "Animation/AnimInstanceProxy.h"
- #include "Animation/SDAnimInstance.h"
- #include "Chooser.h"
- #include "SDTypes.h"
- #include "AbilitySystem/Abilities/SDGA_WallRun.h"
- #include "Animation/AnimNodeReference.h"
- #include "BoneControllers/AnimNode_FootPlacement.h"
- #include "PoseSearch/PoseSearchTrajectoryLibrary.h"
- #include "PoseSearch/PoseSearchDatabase.h"
- #include "PoseSearch/PoseSearchTrajectoryTypes.h"
- #include "BoneControllers/AnimNode_OffsetRootBone.h"
- #include "PoseSearch/PoseSearchInteractionLibrary.h"
- #include "BoneControllers/AnimNode_OrientationWarping.h"
- #include "Character/SDCharacterMovementComponent.h"
- #include "Abilities/Async/AbilityAsync_WaitGameplayTag.h"
- #include "MotionCapture/InterfacePoseSearch.h"
- #include "SDKenyaAnimInstance.generated.h"
- class UPoseSearchDatabase;
- class UAbilityAsync_WaitGameplayEvent;
- class UCharacterMovementComponent;
- class ASDKenyaCharacter;
- struct FAnimNodeReference;
- struct FAnimUpdateContext;
- /**
- *
- */
- USTRUCT()
- struct FTPAnimInstanceProxy : public FAnimInstanceProxy
- {
- GENERATED_BODY()
- protected:
- virtual void InitializeObjects(UAnimInstance* InAnimInstance) override;
- virtual void PreUpdate(UAnimInstance* InAnimInstance, float DeltaSeconds) override;
- virtual void Update(float DeltaSeconds) override;
- public:
- FPoseSearchQueryTrajectory OutTrajectory;
- FPoseSearchQueryTrajectorySample OutTrajectorySample1;
- FPoseSearchQueryTrajectorySample OutTrajectorySample2;
- TWeakObjectPtr<ASDKenyaCharacter> Character;
- TWeakObjectPtr<USDCharacterMovementComponent> CharacterMovement;
- };
- /**
- *
- */
- UCLASS()
- class USDKenyaAnimInstance : public USDAnimInstance, public IInterfacePoseSearch
- {
- GENERATED_BODY()
- public:
- //Assets
- UPROPERTY(EditDefaultsOnly)
- TObjectPtr<UAnimMontage> LandRollMontage;
- //Utility
- bool bHasRun = false;
- FORCEINLINE bool CanRunOnce()
- {
- if (!bHasRun){
- bHasRun = true;
- return true; // First time can run
- }
- return false;
- }
- //Functions fixes for AnimGraph Fast Path
- UPROPERTY(BlueprintReadOnly)
- bool bIsAirDashOrIsDoubleAirDash;
- FORCEINLINE void GetIsAirDashOrIsDoubleAirDash() {bIsAirDashOrIsDoubleAirDash = bIsDoubleAirDash || bIsAirDash; }
- UPROPERTY(BlueprintReadOnly)
- float SlidingDownFalseBlendValue;
- /*FORCEINLINE void GetSlidingDownFalseBlendValue() {SlidingDownFalseBlendValue = Montage_IsActive(SlidingDownMontage) ? 0.1f : 1.5f;}
- UPROPERTY(EditDefaultsOnly)
- TObjectPtr<UAnimMontage> SlidingDownMontage;*/
- protected:
- //Multi Threaded Proxy Logic
- UPROPERTY(Transient)
- FTPAnimInstanceProxy Proxy;
- virtual FTPAnimInstanceProxy* CreateAnimInstanceProxy() override {return &Proxy;}
- virtual void DestroyAnimInstanceProxy(FAnimInstanceProxy* InProxy) override {};
- virtual void NativeThreadSafeUpdateAnimation(float DeltaSeconds) override;
- virtual void NativeInitializeAnimation() override;
- virtual void NativeUpdateAnimation(float DeltaSeconds) override;
- /**/
- UPROPERTY(Transient, BlueprintReadOnly)
- ASDKenyaCharacter* Character;
- UPROPERTY(Transient, BlueprintReadOnly)
- UCharacterMovementComponent* CharacterMovement;
- UPROPERTY()
- TArray<TObjectPtr<AActor>> EmptyArray;
- void GenerateTrajectory(const float DeltaSeconds);
- void UpdateEssentialValue(const float DeltaSeconds);
- void UpdateWallRunValues(const float DeltaSeconds);
- void UpdateFreeClimbValues(const float DeltaSeconds);
- void UpdateSlideValues(const float DeltaSeconds);
- void UpdatePullPushValues(const float DeltaSeconds);
- void UpdateBeamWalkValues(const float DeltaSeconds);
- void UpdateStates();
- void SetMotionMatchingDB();//Works for ST
- /// mocap data update , interface
- virtual FTransform GetInteractionTransform() const override;
- virtual void SetInteractionTransform(FTransform SetTransform) override;
- UPROPERTY(BlueprintReadWrite)
- FAnimNodeReference UpdateRootBoneNode;
- /*UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Anim Nodes", meta=(PinShownByDefault))
- FAnimNode_OffsetRootBone OffsetRootNode;*/
- UPROPERTY(BlueprintReadWrite, Category = "Movement")
- FVector FutureVelocity;
- UPROPERTY(BlueprintReadOnly, Category = "Movement")
- FVector VelocityLastFrame;
- UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Pose Search")
- FPoseSearchTrajectoryData TrajectoryGenerationData_Idle;
- UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Pose Search")
- FPoseSearchTrajectoryData TrajectoryGenerationData_Moving;
- UPROPERTY(BlueprintReadWrite, Category = "Pose Search")
- FPoseSearchQueryTrajectory Trajectory;
- UPROPERTY(BlueprintReadWrite, Category = "Movement")
- FPoseSearchTrajectory_WorldCollisionResults TrajectoryCollision;
- UPROPERTY(BlueprintReadWrite) // Read only
- double Speed2D;
- float PreviousDesiredControllerYaw;
- UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
- FTransform CharacterTransform;
- UPROPERTY(BlueprintReadWrite, Category = "Movement") // NO
- bool bOffsetRootBoneEnabled;
- UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
- FTransform RootTransform;
- UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
- FVector Acceleration;
- UPROPERTY(BlueprintReadWrite, Category = "Movement")
- bool bIsOnGround;
- #pragma region WallRunVariables
- UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
- bool bIsWallRunning = false;
- UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
- bool bIsWallJumping = false;
- UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
- bool bIsWallRunningORJumping = false;
- UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
- bool bIsWallRunningNORJumping = false;
- UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
- EWallRunDirection WallSide = EWallRunDirection::Right;
- UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
- bool bIsWallSideRight = true;
- UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
- bool bIsWallSideLeft = false;
- UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
- float CurrentArcAngle = 0.f;
- UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
- float CurrentTurnRate = 0.f;
- UPROPERTY(BlueprintReadOnly, Category = "Wall Jump", meta = (ToolTip = "The horizontal velocity at which the character will be launched from the wall when wall-jumping."))
- float WallJumpHorizontalVelocity = 800.f;
- UPROPERTY(BlueprintReadOnly, Category = "Wall Jump", meta = (ToolTip = "The vertical velocity at which the character will be launched from the wall when wall-jumping."))
- float WallJumpVerticalVelocity = 500.f;
- UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
- float CurrentSpeed = 0.f;
- UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
- float WallRunAnimPlayRate = 0.f;
- UPROPERTY(BlueprintReadOnly, Category = "Wall Jump")
- float WallJumpAnimationSpeed = 0.f;
- UPROPERTY(BlueprintReadOnly, Category = "Wall Run")
- float HandCorrectionAdditive = 0.f;
- #pragma endregion
- //3rd Batch
- UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
- bool bHasAcceleration;
- UPROPERTY(BlueprintReadWrite, Category = "Movement")
- FVector Velocity_LastFrame;// Read only
- UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
- FVector Velocity;
- UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
- bool bHasVelocity;
- UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
- FVector VelocityAcceleration;
- UPROPERTY(BlueprintReadWrite, Category = "Movement")
- FVector LastNonZeroVelocity;
- UPROPERTY(BlueprintReadWrite, Category = "CrowdAvoidance") // Read only
- double AwarenessSpineRotation;
- UPROPERTY(BlueprintReadOnly, Category = "CrowdAvoidance")
- double AwarenessSpineRotationNegative;
- UPROPERTY(BlueprintReadWrite, Category = "CrowdAvoidance") // Read only
- double AwarenessSpineRotator;
- /*UPROPERTY(BlueprintReadOnly) REPLACED BY DIRECT NODE Ref
- FTransform AnimNodeOffsetRootTransform; */
- // Zipline
- UPROPERTY(BlueprintReadWrite, Category = "Movement")
- bool bIsZiplining;
- public:
- UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
- float AccelerationAmount;
- UPROPERTY(BlueprintReadOnly)
- bool bIsQTEDrone;
- UPROPERTY(BlueprintReadOnly)
- bool bDeathFromAbove;
- UPROPERTY(BlueprintReadOnly)
- bool bQTEDroneSuccess;
- UPROPERTY(BlueprintReadOnly)
- bool bQTEDroneFailure;
- //Brawler Death From Above
- UPROPERTY(BlueprintReadOnly)
- bool bDeathFromAboveNPC;
- UPROPERTY(BlueprintReadOnly)
- bool bDeathFromAboveNPCLoopStart;
- UPROPERTY(BlueprintReadOnly)
- bool bDeathFromAboveNPCPunchStart;
- UPROPERTY(BlueprintReadOnly)
- bool bDeathFromAboveNPCBackFlipStart;
- UPROPERTY(BlueprintReadOnly, Category = "Takedown")
- float TakeDownNPCLoopAnimSpeed;
- UPROPERTY(BlueprintReadOnly)
- bool bAllowImmediateRotation;
- TArray<FName> CurrentDatabaseTags;
- UPROPERTY(BlueprintReadOnly)
- int32 MMDatabaseLOD;
- UPROPERTY(EditDefaultsOnly, Category = "Motion Matching | CHT")
- TObjectPtr<const UChooserTable> MainCHT;
- UPROPERTY(EditDefaultsOnly, Category = "Motion Matching | CHT")
- TObjectPtr<const UChooserTable> CombatCHT;
- UPROPERTY(EditDefaultsOnly, Category = "Motion Matching | CHT")
- TObjectPtr<const UChooserTable> MiniGunCHT;
- UPROPERTY(EditDefaultsOnly, Category = "Motion Matching | CHT")
- TObjectPtr<const UChooserTable> PsycheCHT;
- UPROPERTY(EditDefaultsOnly, Category = "Motion Matching | CHT")//none
- const UChooserTable* CurrentCHT = MainCHT;
- UPROPERTY(Transient,EditDefaultsOnly, BlueprintReadOnly, Category = "Pose Search")
- TWeakObjectPtr<const UPoseSearchDatabase> CurrentSelectedDatabase;
- // Movement Mode
- UPROPERTY(BlueprintReadWrite, Category = "Movement") // Read only
- EMM_MovementMode MovementMode = EMM_MovementMode::OnGround;
- UPROPERTY(BlueprintReadWrite, Category = "Movement")// Read only
- EMM_MovementMode MovementMode_LastFrame = EMM_MovementMode::OnGround;
- UPROPERTY( BlueprintReadWrite, Category = "Movement") // Read only
- EMM_RotationMode RotationMode = EMM_RotationMode::OrientToMovement;
- UPROPERTY( BlueprintReadWrite, Category = "Movement") // Read only
- EMM_RotationMode RotationMode_LastFrame = EMM_RotationMode::OrientToMovement;
- UPROPERTY( BlueprintReadWrite, Category = "Movement") // Read only
- EMM_MovementState MovementState_LastFrame = EMM_MovementState::Idle;
- UPROPERTY( BlueprintReadWrite, Category = "Movement") // Read only
- EMM_MovementState MovementState = EMM_MovementState::Idle;
- UPROPERTY( BlueprintReadWrite, Category = "Movement")// Read only
- EMM_Gait Gait_LastFrame = EMM_Gait::Walk;
- UPROPERTY( BlueprintReadWrite, Category = "Movement")// Read only
- EMM_Gait Gait = EMM_Gait::Walk;
- UPROPERTY( BlueprintReadWrite, Category = "Movement")// Read only
- EMM_Gait PreviousGroundedGait = EMM_Gait::Walk;
- UPROPERTY( BlueprintReadWrite, Category = "Movement")// Read only
- EMM_Stance Stance_LastFrame = EMM_Stance::Stand;
- UPROPERTY( BlueprintReadWrite, Category = "Movement")// Read only
- EMM_Stance Stance = EMM_Stance::Stand;
- UPROPERTY( BlueprintReadWrite, Category = "Overlay")
- EOverlayState OverlayState = EOverlayState::Unarmed;
- UPROPERTY( BlueprintReadWrite, Category = "Overlay")
- EOverlayState PreviousOverlayState = EOverlayState::Unarmed;
- UPROPERTY( BlueprintReadWrite, Category = "Climbing")
- EClimbState ClimbState = EClimbState::Default;
- UPROPERTY( BlueprintReadWrite, Category = "Climbing")
- EReachDirection ReachDirection = EReachDirection::Up;
- UPROPERTY( BlueprintReadOnly, Category = "Climbing")
- EClimbTransition ClimbTransition = EClimbTransition::Shimmy;
- // Motion Matching
- UPROPERTY( BlueprintReadWrite, Category = "Motion Matching") // ReadOnly
- E_KenyaMotionMatchingDB MotionMatchingDB_LastFrame = E_KenyaMotionMatchingDB::Normal;
- UPROPERTY( BlueprintReadWrite, Category = "Motion Matching") // ReadOnly
- E_KenyaMotionMatchingDB MotionMatchingDB = E_KenyaMotionMatchingDB::Normal;
- UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Motion Matching")
- bool bChangeMotionMatchingDBGet_MMInterruptNow=false;
- UFUNCTION(BlueprintCallable, Category = "Motion Matching")
- void ChangeMMInterruptToTrue(); //To force to change MMInterrupt to true for a while
- FTimerHandle TimerHandleInterruptToTrue;
- UFUNCTION()
- void ChangeMMInterruptToTrueNow();
- UPROPERTY(BlueprintReadOnly, Category = "Movement")
- bool bIsADS;//
- UPROPERTY(BlueprintReadOnly, Category = "Movement")
- bool bIsTurningInPlace;
- UFUNCTION(BlueprintCallable)
- FORCEINLINE void IsTurningInPlaceUpdate(){bIsTurningInPlace = CurrentDatabaseTags.Contains("TurnInPlace");}
- // cover system
- UPROPERTY(BlueprintReadWrite, Category = "Cover")
- bool bInCover=false;
- UPROPERTY(BlueprintReadWrite, Category = "Cover")
- bool bIsCoverPivotRight=false;
- UPROPERTY(BlueprintReadWrite, Category = "Cover")
- bool bIsCoverPivoting=false;
- UPROPERTY(BlueprintReadWrite, Category = "Cover")
- bool bInCoverPeeking=false;
- UPROPERTY(BlueprintReadWrite, Category = "Cover")
- bool bIsVaultingCover=false;
- UPROPERTY(BlueprintReadWrite, Category = "Cover")
- bool bIsCoverRight=true;
- UPROPERTY(BlueprintReadWrite, Category = "Cover")
- bool bExitingCover=false;
- UPROPERTY(BlueprintReadWrite, Category = "Cover")
- bool bSkipTransition=false;
- UPROPERTY(BlueprintReadWrite, Category = "Cover")
- bool bIsMovingNow=false;
- UPROPERTY(BlueprintReadWrite, Category = "Cover")
- bool bInCombat=false;
- UPROPERTY(BlueprintReadWrite, Category = "Cover")
- bool bCoverEnteredFully;
- UFUNCTION(BlueprintCallable)
- void CoversystemMovingCheckUpdate();
- // Timer handle declaration
- FTimerHandle TimerHandleCoverStart;
- //Cover moving check start timer
- UFUNCTION(BlueprintCallable)
- void StartTimerCover();
- //Cover moving check stop timer
- UFUNCTION(BlueprintCallable)
- void StopTimerCover();
- // shockfire AimOffset system
- UPROPERTY(BlueprintReadWrite, Category = "Shockfire")
- float ShockPitch;
- UPROPERTY(BlueprintReadWrite, Category = "Shockfire")
- float ShockYaw;
- // Idle Aim offset
- UPROPERTY(BlueprintReadWrite, Category = "AimOffset")
- bool UseIdleAimOffset=true;
- UPROPERTY(BlueprintReadWrite, Category = "AimOffset")
- float IdleAimOffsetYaw;
- UPROPERTY(BlueprintReadWrite, Category = "AimOffset")
- float IdleAimOffsetPitch;
- void IdleAimOffsetYawPitchUpdate(float DeltaTime);
- //Cover moving check stop timer
- UFUNCTION(BlueprintCallable)
- void ShockFirePawPitchUpdate();
- // Timer handle
- FTimerHandle TimerHandleShockAOScan;
- //Cover moving check stop timer
- UFUNCTION(BlueprintCallable)
- void ShockFireAOchangeStateScanBack();
- FTimerHandle TimerHandleStateShockFireAimOfsett;
- UFUNCTION(BlueprintCallable)
- void SetStateShockFireAimOfsett(bool start);
- ///
- UPROPERTY(BlueprintReadWrite, Category = "Shockfire")
- bool ShockFireUseRightHand=false;
- UPROPERTY(BlueprintReadWrite, Category = "Shockfire")
- bool bUseShockFire = false;
- // psycheScan normal
- UPROPERTY(BlueprintReadWrite, Category = "Shockfire")
- bool psycheScanNoUseRightHandNow=false;
- //idleTurnInplace
- UPROPERTY(BlueprintReadWrite, Category = "psycheScan")
- bool idleTurnInplace = false;
- void idleTurnInplaceTick();
- //minigun
- UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Minigun")
- bool bMinigunActive;
- UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="Minigun")
- float pitchMinigun;
- FTimerHandle MyTimerHandle;
- UFUNCTION(BlueprintCallable)
- void StartMinigunShooting(bool startShootingAimOffset);
- UFUNCTION()
- void PlayerPitchUpdate();
- // PsycheScan Aim + Turn inplace
- UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="PsycheScan")
- bool bUsePsycheScanTurnInplaceSystem;
- float TurnYawCurveValue;
- UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="PsycheScan")
- float RootYawOffset1;
- float YawDeltaSinceLastUpdate2;
- UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="PsycheScan")
- float TurnInPlaceAnimTime;
- float TurninPlaceRotationDirection;
- UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="PsycheScan")
- FVector2D RootYawOffsetAngleClamp = FVector2D(-80.0f,80.0f);
- FRotator WorldRotation;
- UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="PsycheScan")
- UAnimSequence* TurninPlaceRight;
- UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="PsycheScan")
- UAnimSequence* TurninPlaceLeft;
- bool IsFirstUpdate=true;
- float PreviousTurnYawCurveValue;
- UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
- void SetRootYawOffset1(float InRootYawOffset);
- UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
- void ProcessTurnYawCurve();
- UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
- void UpdateRootYawOffset(float InDeltaTime);
- UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
- void UpdateIdleState(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
- UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
- void UpdateRotationData();
- UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
- void SetupTurnInPlaceAnim(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
- UAnimSequence* SelectTurnInPlaceAnimation(float Direction);
- UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
- void UpdateTurnInPlaceAnim(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
- UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
- void SetUpTurnInPlaceRotationState(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
- //void SetUpTurnInPlaceRecoveryState(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
- UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
- void UpdateTurnInPlaceRecoveryAnim(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
- //void ResetIdleBreakTransitionLogic();
- //void ChooseIdleBreakDelayTime();
- //void GetMainAnimBPThreadSafe();
- //void SetUpIdleState();
- //void GetMainAnimBPThreadSafe_0();
- //void CheckToRestartANim();
- UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
- void OnStateEntry(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
- UFUNCTION(BlueprintCallable, Category="PsycheScan",meta = (BlueprintThreadSafe))
- void OnStateFullyBlendedIn_0(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
- //void OnStateFullyBlendedOut(const FAnimUpdateContext& Context,const FAnimNodeReference& Node);
- // Additional Transform Variables
- UPROPERTY(BlueprintReadOnly, Category = "Character")
- FTransform LeftStepStartTransform;
- UPROPERTY(BlueprintReadOnly, Category = "Turn In Place")
- FTransform RightStepStartTransform;
- UPROPERTY(BlueprintReadOnly, Category = "Turn In Place")
- FTransform TurnInPlace_LeftFootTransform;
- UPROPERTY(BlueprintReadOnly, Category = "Turn In Place")
- FTransform TurnInPlace_RightFootTransform;
- // Float and Boolean Variables
- UPROPERTY(BlueprintReadOnly, Category = "Footstep")
- double LeftFootstepDuration;//
- UPROPERTY(BlueprintReadOnly, Category = "Footstep")
- double RightFootstepDuration;//
- UPROPERTY(BlueprintReadOnly, Category = "Footstep")
- bool bMoveLeftFoot;//
- UPROPERTY(BlueprintReadOnly, Category = "Footstep")
- bool bMoveRightFoot;//
- // Rotation and Movement
- UPROPERTY(BlueprintReadOnly, Category = "Movement")
- double TurnInPlaceDuration;//
- UPROPERTY(BlueprintReadOnly, Category = "Movement")
- bool bIsOrientingToMovement; //
- UPROPERTY(BlueprintReadOnly, Category = "Movement")
- bool bIsUsingDesiredRotation; //
- // Miscellaneous
- UPROPERTY(BlueprintReadOnly, Category = "Weapon")
- FTransform MinigunTransform;
- UPROPERTY(BlueprintReadOnly, Category = "Combat")
- bool bAiming;//
- UPROPERTY(BlueprintReadOnly, Category = "Combat")
- FTransform ProjectileLeftHandPlacement;
- // Landing and Jumping
- UPROPERTY(BlueprintReadOnly, Category = "Landing")
- bool bLocomotionLanded;//
- UPROPERTY(BlueprintReadOnly, Category = "Landing")
- FVector LandVelocity;
- UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Landing")
- double HeavyLandSpeedThreshold = 1125;//
- UPROPERTY(BlueprintReadOnly, Category = "Landing")
- TArray<FName> FloorActorTags;
- UPROPERTY(BlueprintReadOnly, Category = "Jumping")
- bool bIsDoubleJump;//
- UPROPERTY(BlueprintReadOnly, Category = "Jumping")
- bool bLandFromDoubleJump;//
- UPROPERTY(BlueprintReadOnly, Category = "Jumping")
- bool bIsDoubleJumpStart;//
- // Air Dash
- UPROPERTY(BlueprintReadOnly, Category = "Movement")
- bool bIsAirDash;//
- UPROPERTY(BlueprintReadOnly, Category = "Movement")
- bool bIsDoubleAirDash;//
- UPROPERTY(BlueprintReadOnly, Category = "Movement")
- bool bLandFromAirDash;//
- // Climbing
- UPROPERTY(BlueprintReadWrite, Category = "Climbing")
- bool bIsClimbing;//
- UPROPERTY(BlueprintReadWrite, Category = "Climbing")
- bool bIsClimbReaching;//
- UPROPERTY(BlueprintReadWrite, Category = "Climbing")
- bool bIsClimbReachingValid;//
- UPROPERTY(BlueprintReadOnly, Category = "Climbing")
- bool bIsReachChangingDirection;//
- UPROPERTY(BlueprintReadWrite, Category = "Climbing")
- bool bStandShimmyRight; //
- UPROPERTY(BlueprintReadWrite, Category = "Input")
- FVector2D CachedInputVector;
- UPROPERTY(BlueprintReadOnly, Category = "Input")
- bool bIsClimbTransitioning;//
- UPROPERTY(BlueprintReadWrite, Category = "Input")
- FVector2D InputRawMovementSpeed;
- UPROPERTY(BlueprintReadWrite, Category = "Input")
- FVector2D InputMovementSpeed;
- UPROPERTY(BlueprintReadOnly, Category = "Input")
- bool bIsPerchTurnEnded;//
- UPROPERTY(BlueprintReadWrite, Category = "Input")// Read only
- FVector InputVector;
- // Climb and Pipe Climb
- UPROPERTY(BlueprintReadWrite, Category = "Climbing")
- bool bPipeClimbRight;//
- UPROPERTY(BlueprintReadWrite, Category = "Climbing") // Read only
- FVector RightVector;
- UPROPERTY(BlueprintReadWrite, Category = "Climbing") // Read only
- FVector ForwardVector;
- UPROPERTY(BlueprintReadOnly, Category = "Climbing")
- FVector StopReachingVector;
- UPROPERTY(BlueprintReadOnly, Category = "Climbing")
- double ClimbTransitionBlendTime;
- UPROPERTY(BlueprintReadOnly, Category = "Climbing")
- bool bIsClimbReTransitioning;//
- // Free Climbing
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bIsFreeClimbing;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bIsFreeClimbingOnCeiling;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bFreeClimbJumpOff;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bIsFreeClimbDashing;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bIsFreeClimbTurningCorner;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bUsedClimbDashBackup;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bFreeClimbTurnRight;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bFreeClimbTurnInner;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bIsFreeClimbSwinging;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bIsFreeClimbSwingLeaping;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bIsFreeClimbOnEdge;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bFreeClimbTurnAround;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bFreeClimbNotMoving;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bFreeClimbToDashBackup;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bFreeClimbToDash;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bFreeClimbToTurnCorner;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bIsFreeClimbingOnWall;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- bool bFreeClimbEnterFromTop;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- float FreeClimbTrueBlendValue = 0.2f;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- EMM_MovementMode FreeClimbFrom = EMM_MovementMode::OnGround;
- bool bCheckedFreeClimbFrom;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- FVector2D FreeClimbDashVelocity;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- FVector2D FreeClimbInput;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- float FreeClimbIKAlpha;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- float FreeClimbSpeed;
- UPROPERTY(BlueprintReadOnly, Category = "Free Climb")
- float FreeClimbCeilingSpeed;
- UFUNCTION(Category = "Free Climb", BlueprintCallable, meta = (BlueprintThreadSafe))
- void OnFreeClimbBecomeRelevant(const FAnimUpdateContext& Context, const FAnimNodeReference& Node);
- // Interaction and Character
- UPROPERTY(BlueprintReadWrite, Category = "Motion Matching")
- FTransform InteractionTransform;
- UPROPERTY(BlueprintReadOnly, Category = "Character")
- bool bIsKenyaCharacterValid;//
- UPROPERTY(BlueprintReadOnly, Category = "Motion Matching")
- FVector Trj_FutureVelocity = FVector::ZeroVector;
- // Trajectory
- UPROPERTY(BlueprintReadOnly, Category = "Trajectory")
- FVector Trj_PastVelocity;
- UPROPERTY(BlueprintReadOnly, Category = "Trajectory")
- FVector Trj_CurrentVelocity;
- // Character State
- UPROPERTY(BlueprintReadWrite, Category = "Character") // Only Read
- FTransform CharacterTransformLastFrame;
- UPROPERTY(BlueprintReadWrite, Category = "Character") // Only Read
- FVector AccelerationLastFrame;
- // Root Translation
- UPROPERTY(BlueprintReadOnly, Category = "Root Translation")
- double OffsetRootTranslationRadius;
- // Foot Placement Settings
- UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Foot Placement")
- FFootPlacementPlantSettings PlantSettings_Default;
- UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Foot Placement")
- FFootPlacementPlantSettings PlantSettings_Stops;
- UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Foot Placement")
- FFootPlacementInterpolationSettings InterpolationSettings_Default;
- UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Foot Placement")
- FFootPlacementInterpolationSettings InterpolationSettings_Stops;
- /*
- *FUNCTIONS CALLED FROM OTHER OBJS todo Run On Tick
- */
- UFUNCTION(BlueprintPure, Category = "External Functions", meta = (BlueprintThreadSafe))
- bool IsPivoting() const;
- UFUNCTION(BlueprintPure, Category = "External Functions", meta = (BlueprintThreadSafe))
- bool IsStarting();
- /*UFUNCTION(BlueprintPure, Category = "External Functions", meta = (BlueprintThreadSafe))
- bool JustLanded_Light() const;*/
- /*UFUNCTION(BlueprintPure, Category = "External Functions", meta = (BlueprintThreadSafe))
- bool JustLanded_Heavy() const;*/
- UPROPERTY(BlueprintReadOnly, Category = "CHT | Variables")
- bool bIsPivoting;
- FORCEINLINE void IsPivotingUpdate()
- {
- FRotator Delta = FutureVelocity.ToOrientationRotator() - Velocity.ToOrientationRotator();
- Delta.Normalize();
- bIsPivoting = FMath::Abs( Delta.Yaw ) >= (RotationMode == EMM_RotationMode::OrientToMovement ? 60.f : 40.f);
- /*todo More Optimized version to test
- *bIsPivoting = FMath::Abs([&]() -> float {
- const float d = (FMath::Atan2(FutureVelocity.Y, FutureVelocity.X) - FMath::Atan2(Velocity.Y, Velocity.X)) * 57.29578f;
- return d > 180.f ? d - 360.f : d < -180.f ? d + 360.f : d;
- }()) >= (RotationMode == EMM_RotationMode::OrientToMovement ? 60.f : 40.f);*/
- }
- UPROPERTY(BlueprintReadOnly, Category = "CHT | Variables")
- bool bIsStarting;
- FORCEINLINE void IsStartingUpdate()
- {
- IsMovingUpdate();
- bIsStarting = bIsMoving && (FutureVelocity.Size2D() >= Velocity.Size2D()+100) && !CurrentDatabaseTags.Contains(FName("Pivots"));
- }
- UPROPERTY(BlueprintReadOnly, Category = "CHT | Variables")
- bool bJustLandedLight;
- FORCEINLINE void JustLandedLightUpdate(){bJustLandedLight = bLocomotionLanded && FMath::Abs(LandVelocity.Z) < FMath::Abs(HeavyLandSpeedThreshold);}
- UPROPERTY(BlueprintReadOnly, Category = "CHT | Variables")
- bool bJustLandedHeavy;
- FORCEINLINE void JustLandedHeavyUpdate(){ bJustLandedHeavy = bLocomotionLanded && FMath::Abs(LandVelocity.Z) >= FMath::Abs(HeavyLandSpeedThreshold) && !FloorActorTags.Contains("SlideSurface");}
- bool JustLandedSprintingDoubleJump() const; //Not called from CHT
- // Sliding
- UPROPERTY(BlueprintReadOnly, Category = "Sliding")
- bool bIsSlidingDown;
- UPROPERTY(BlueprintReadWrite, Category = "Sliding")
- ESlideType SlideType;
- UPROPERTY(BlueprintReadOnly, Category = "Sliding")
- bool bWasSliding;
- UPROPERTY(BlueprintReadOnly, Category = "Sliding")
- float SlidePitch;
- UPROPERTY(BlueprintReadOnly, Category = "Sliding")
- bool bIsSlidingOrSlideJumping;
- //Pull Push
- UPROPERTY(BlueprintReadOnly, Category = "Pull Push")
- bool bIsPulling;
- //Beam
- UPROPERTY(BlueprintReadOnly, Category = "Beam")
- bool bEnableBeamWalk;
- UPROPERTY(BlueprintReadOnly, Category = "Beam")
- bool bBeamWobble;
- /*
- * ANIM GRAPH
- */
- UPROPERTY(BlueprintReadOnly, Category = "AnimGraph")
- FQuat DesiredFacing;
- FORCEINLINE void DesiredFacingUpdate()
- {
- FPoseSearchQueryTrajectorySample OutTrajectorySample;
- UPoseSearchTrajectoryLibrary::GetTrajectorySampleAtTime(Trajectory, 0.5,OutTrajectorySample);
- DesiredFacing = OutTrajectorySample.Facing;
- }
- UPROPERTY(BlueprintReadOnly, Category = "Update Variables")
- bool bIsMoving;
- UFUNCTION()
- FORCEINLINE void IsMovingUpdate()
- {
- constexpr float Threshold = 0.1f;
- bIsMoving = !Velocity.Equals( FVector::ZeroVector, Threshold) && !FutureVelocity.Equals( FVector::ZeroVector, Threshold);
- }
- UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Offset Root Bone", meta = (BlueprintThreadSafe))
- bool IsMoving() const;
- UPROPERTY(BlueprintReadOnly, Category = "Update Variables")
- float MMBlendTime;
- UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Offset Root Bone", meta = (BlueprintThreadSafe))
- float Get_MMBlendTimeUpdate() const;
- FORCEINLINE void MMBlendTimeUpdate()
- {
- switch (MovementMode) {
- case EMM_MovementMode::OnGround:
- //if ((PreviousGroundedGait == EMM_Gait::Run or PreviousGroundedGait == EMM_Gait::Sprint) && Gait == EMM_Gait::Walk){return 0.4f;}
- switch (MovementMode_LastFrame)
- {
- case EMM_MovementMode::OnGround:
- MMBlendTime = 0.4f;
- break;
- case EMM_MovementMode::InAir:
- MMBlendTime = 0.2f;
- break;
- }
- break;
- case EMM_MovementMode::InAir:
- if (Velocity.Z > 100.0f)
- {
- MMBlendTime = 0.15f;
- }
- MMBlendTime =0.5f;
- break;
- }
- }
- UPROPERTY(BlueprintReadOnly, Category = "Update Variables")
- float MMNotifyRecencyTimeout;
- UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Offset Root Bone", meta = (BlueprintThreadSafe))
- float Get_MMNotifyRecencyTimeoutUpdate() const;
- FORCEINLINE void MMNotifyRecencyTimeoutUpdate()
- {
- switch (Gait)
- {
- case EMM_Gait::Walk:
- MMNotifyRecencyTimeout = 0.2f;
- break;
- case EMM_Gait::Run:
- MMNotifyRecencyTimeout = 0.2f;
- break;
- case EMM_Gait::Sprint:
- MMNotifyRecencyTimeout = 0.16f;
- break;
- }
- }
- EPoseSearchInterruptMode Get_MMInterrupt() const;
- UFUNCTION(Category = "MotionMatching", BlueprintCallable, meta = (BlueprintThreadSafe))
- void Update_MotionMatchingDBS(const FAnimUpdateContext& Context, const FAnimNodeReference& Node);
- UFUNCTION(Category = "MotionMatching", BlueprintCallable, meta = (BlueprintThreadSafe))
- void Update_MotionMatchingPostSelection(const FAnimUpdateContext& Context, const FAnimNodeReference& Node);
- UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Motion Matching", meta = (BlueprintThreadSafe))
- FVector2D Get_LeanAmount() const;
- UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Offset Root Bone", meta = (BlueprintThreadSafe))
- EOffsetRootBoneMode Get_OffsetRootTranslationMode() const;
- UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Offset Root Bone", meta = (BlueprintThreadSafe))
- EOffsetRootBoneMode Get_OffsetRootRotationMode() const;
- UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Offset Root Bone", meta = (BlueprintThreadSafe))
- float Get_OffsetRootTranslationHalfLife() const;
- UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Foot Placement", meta = (BlueprintThreadSafe))
- FFootPlacementInterpolationSettings Get_FootPlacementInterpolationSettings() const;
- UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Foot Placement", meta = (BlueprintThreadSafe))
- FFootPlacementPlantSettings Get_FootPlacementPlantSettings() const;
- UFUNCTION(BlueprintPure, Category = "Motion Matching", meta = (BlueprintThreadSafe))
- FVector CalculateRelativeAccelerationAmount() const;
- UPROPERTY(BlueprintReadOnly, Category = "AnimGraph | Blend Stack Input")
- EOrientationWarpingSpace OrientationWarpingSpace;
- FORCEINLINE void OrientationWarpingWarpingSpaceUpdate()
- {
- OrientationWarpingSpace = bOffsetRootBoneEnabled ? EOrientationWarpingSpace::RootBoneTransform : EOrientationWarpingSpace::ComponentTransform;
- }
- /*UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Blend Stack Input", meta = (BlueprintThreadSafe))
- EOrientationWarpingSpace Get_OrientationWarpingWarpingSpaceN() const;*/
- UPROPERTY(BlueprintReadOnly, Category = "AnimGraph | Blend Stack Input")
- bool bEnableSteering;
- FORCEINLINE void EnableSteeringUpdate() {
- bEnableSteering = MovementState == EMM_MovementState::Moving or MovementMode == EMM_MovementMode::OnGround;
- }
- /*float LeanTimer;
- UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Leaning")
- float MaxLeanDuration = 2.0f; */
- UFUNCTION(BlueprintPure, Category = "AnimGraphFunctions | Offset Root Bone", meta = (BlueprintThreadSafe))
- float Get_RightLean();
- #pragma region Delegates
- UPROPERTY()
- UAbilityAsync_WaitGameplayEvent* OnLandingTask;
- UFUNCTION(BlueprintCallable)
- void OnLandingEventReceived(FGameplayEventData Payload);
- FTimerHandle LandingResetTimerHandle;
- UFUNCTION()
- void HardLandingOnRollMontageBlendOut(UAnimMontage* Montage, bool bInterrupted);
- UPROPERTY()
- UAbilityAsync_WaitGameplayEvent* OnJumpDoubleTask;
- UFUNCTION(BlueprintCallable)
- void OnJumpDoubleTaskReceived(FGameplayEventData Payload);
- FTimerHandle DoubleJumpTimerHandle;
- UPROPERTY()
- UAbilityAsync_WaitGameplayEvent* OnAirDashTask;
- UFUNCTION(BlueprintCallable)
- void OnAirDashTaskReceived(FGameplayEventData Payload);
- UPROPERTY()
- UAbilityAsync_WaitGameplayEvent* OnClimbBeginTask;
- UFUNCTION(BlueprintCallable)
- void OnClimbBeginTaskReceived(FGameplayEventData Payload);
- UFUNCTION(BlueprintCallable)
- void OnClimbBegin();
- UPROPERTY()
- UAbilityAsync_WaitGameplayEvent* OnClimbReachBeginTask;
- UPROPERTY()
- UAbilityAsync_WaitGameplayEvent* OnClimbReachFinishedTask;
- UFUNCTION(BlueprintCallable)
- void OnClimbReachFinishedTaskReceived(FGameplayEventData Payload);
- UPROPERTY()
- UAbilityAsync_WaitGameplayEvent* OnClimbTransitionTask;
- UFUNCTION(BlueprintCallable)
- void OnClimbTransitionTaskReceived(FGameplayEventData Payload);
- FTimerHandle ClimbTransitionTimerHandle;
- UPROPERTY()
- UAbilityAsync_WaitGameplayEvent* OnPerchTurnEndedTask;
- UFUNCTION(BlueprintCallable)
- void OnPerchTurnEndedTaskReceived(FGameplayEventData Payload);
- FTimerHandle PerchTurnEndedTimerHandle;
- UPROPERTY()
- UAbilityAsync_WaitGameplayEvent* OnStandBeginTask;
- UFUNCTION(BlueprintCallable)
- void OnStandBeginTaskReceived(FGameplayEventData Payload);
- UPROPERTY()
- UAbilityAsync_WaitGameplayTagAdded* OnFreeClimbJumpTagAddedTask;
- UFUNCTION(BlueprintCallable)
- void OnFreeClimbJumpTagAddedTaskReceived();
- UPROPERTY()
- UAbilityAsync_WaitGameplayTagRemoved* OnFreeClimbJumpTagRemovedTask;
- UFUNCTION(BlueprintCallable)
- void OnFreeClimbJumpTagRemovedTaskReceived();
- #pragma endregion
- //BlendStack
- UFUNCTION(Category = "BlendStack", BlueprintCallable, meta = (BlueprintThreadSafe))
- void UpdateBlendStack(const FAnimUpdateContext& Context, const FAnimNodeReference& Node);
- UPROPERTY(BlueprintReadOnly, Category = "Motion Matching")
- float AnimTime;
- UPROPERTY(BlueprintReadOnly, Category = "Motion Matching")
- TObjectPtr<UAnimationAsset> AnimAsset;
- UPROPERTY(BlueprintReadOnly, Category = "Motion Matching")
- float OrientationAlpha;
- //Test
- UFUNCTION(BlueprintNativeEvent)
- void TaskTestTiming();
- UFUNCTION(BlueprintCallable)
- bool CheckCombatStance() const;
- UFUNCTION(BlueprintCallable)
- void CheckCombatStanceV();
- UPROPERTY(BlueprintReadWrite)
- bool bCombatStance;
- UFUNCTION(Category = "BlendStack", BlueprintCallable, meta = (BlueprintThreadSafe))
- void UpdateOffSetRootNode( const FAnimUpdateContext& Context, const FAnimNodeReference& Node);
- bool bInitialized;
- UPROPERTY(BlueprintReadOnly)
- UBlendSpace* CurrentLeanBlendMontage;
- UPROPERTY(EditDefaultsOnly)
- TObjectPtr<UBlendSpace> WalkLeanBlendMontage;
- UPROPERTY(EditDefaultsOnly)
- TObjectPtr<UBlendSpace> RunLeanBlendMontage;
- UPROPERTY(EditDefaultsOnly)
- TObjectPtr<UBlendSpace> SprintLeanBlendMontage;
- UPROPERTY(EditDefaultsOnly)
- TObjectPtr<UBlendSpace> CombatWalkLeanBlendMontage;
- UPROPERTY(EditDefaultsOnly)
- TObjectPtr<UBlendSpace> CombatRunLeanBlendMontage;
- UPROPERTY(EditDefaultsOnly)
- TObjectPtr<UBlendSpace> CombatSprintLeanBlendMontage;
- UPROPERTY(EditDefaultsOnly)
- float BlendSpaceAmount = 1;
- UFUNCTION(Category = "MotionMatching", BlueprintCallable, meta = (BlueprintThreadSafe))
- void OnZiplineInitialUpdate(const FAnimUpdateContext& Context, const FAnimNodeReference& Node);
- protected:
- UPROPERTY(BlueprintReadOnly)
- bool bIsPossessingRobot = false;
- };
- [CPP]
- void FTPAnimInstanceProxy::InitializeObjects(UAnimInstance* InAnimInstance)
- {
- FAnimInstanceProxy::InitializeObjects(InAnimInstance);
- Character = Cast<ASDKenyaCharacter>(InAnimInstance->TryGetPawnOwner());
- if (!Character.Get()) return;
- CharacterMovement = Cast<USDCharacterMovementComponent>(Character->GetCharacterMovement());
- }
- void FTPAnimInstanceProxy::PreUpdate(UAnimInstance* InAnimInstance, const float DeltaSeconds)
- {
- FAnimInstanceProxy::PreUpdate(InAnimInstance, DeltaSeconds);
- }
- void FTPAnimInstanceProxy::Update(const float DeltaSeconds)
- {
- FAnimInstanceProxy::Update(DeltaSeconds);
- }
- void USDKenyaAnimInstance::NativeInitializeAnimation()
- {
- Super::NativeInitializeAnimation();
- EmptyArray.Reserve(0);
- Character = Cast<ASDKenyaCharacter>(TryGetPawnOwner());
- if (!Character) return;
- //GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Blue, TEXT(""));
- CharacterMovement = Character->GetCharacterMovement();
- FTimerHandle TimerWait;
- GetWorld()->GetTimerManager().SetTimer(TimerWait, FTimerDelegate::CreateWeakLambda(this, [this]()
- {
- bInitialized = true;
- }), 0.1, false);
- OnFreeClimbJumpTagAddedTask = UAbilityAsync_WaitGameplayTagAdded::WaitGameplayTagAddToActor(Character, FGameplayTag::RequestGameplayTag(FName("AbilityEvent.AnimNotify.Character.FreeClimb.JumpOff")));
- OnFreeClimbJumpTagAddedTask->Added.AddDynamic(this, &USDKenyaAnimInstance::OnFreeClimbJumpTagAddedTaskReceived);
- OnFreeClimbJumpTagRemovedTask = UAbilityAsync_WaitGameplayTagRemoved::WaitGameplayTagRemoveFromActor(Character, FGameplayTag::RequestGameplayTag(FName("AbilityEvent.AnimNotify.Character.FreeClimb.JumpOff")));
- OnFreeClimbJumpTagRemovedTask->Removed.AddDynamic(this, &USDKenyaAnimInstance::OnFreeClimbJumpTagRemovedTaskReceived);
- }
- void USDKenyaAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
- {
- if (!bInitialized) return;
- //BP Native Event Fixes **GAME THREAD**
- //EssentialValueFix();
- //CHT Updates **GAME THREAD**
- if (MovementMode == EMM_MovementMode::OnGround)
- {
- JustLandedLightUpdate();
- JustLandedHeavyUpdate();
- CheckCombatStanceV();
- if (MovementState == EMM_MovementState::Moving )
- {
- IsStartingUpdate();
- IsPivotingUpdate();
- IsStartingUpdate();
- }
- }
- //Core ST Option
- //UpdateEssentialValueST(DeltaSeconds);
- //GenerateTrajectoryST(DeltaSeconds);
- //TaskTestTiming();
- //UpdateStatesST();
- //SetMotionMatchingDB();
- //CHT Variables to update on **GAME THREAD**GEngine->AddOnScreenDebugMessage(-1, 0.f, FColor::Blue, FString::Printf(TEXT("Speed: %f"),Speed2D));
- }
- void USDKenyaAnimInstance::NativeThreadSafeUpdateAnimation(float DeltaSeconds)
- {
- if (!bInitialized) return;
- //AnimGraph Variable Updates
- /*MMBlendTimeUpdate();
- MMNotifyRecencyTimeoutUpdate();*/
- GetIsAirDashOrIsDoubleAirDash();
- //GetSlidingDownFalseBlendValue(); Apparently not used anymore
- IsMovingUpdate();
- //Motion Matching Core
- UpdateEssentialValue(DeltaSeconds);
- UpdateWallRunValues(DeltaSeconds);
- UpdateFreeClimbValues(DeltaSeconds);
- UpdateSlideValues(DeltaSeconds);
- UpdatePullPushValues(DeltaSeconds);
- UpdateBeamWalkValues(DeltaSeconds);
- GenerateTrajectory(DeltaSeconds);
- UpdateStates();
- SetMotionMatchingDB();
- IdleAimOffsetYawPitchUpdate(DeltaSeconds);
- idleTurnInplaceTick();
- // PsycheScan Turn in place system
- UpdateRotationData();
- UpdateRootYawOffset(DeltaSeconds);
- //UpdateRotationData();
- //GEngine->AddOnScreenDebugMessage(-1, 0.f, FColor::Blue, FString::Printf(TEXT("Speed: %f"),Speed2D));
- //
- bIsPossessingRobot = Character->GetAbilitySystemComponent()->HasMatchingGameplayTag(FGameplayTag::RequestGameplayTag(FName("Status.Psyche.Nocked")));
- }
- void USDKenyaAnimInstance::SetMotionMatchingDB()
- {
- MotionMatchingDB_LastFrame = MotionMatchingDB;
- switch (OverlayState) {
- case EOverlayState::Unarmed:
- case EOverlayState::Powercell:
- //MotionMatchingDB = E_KenyaMotionMatchingDB::Normal;
- MotionMatchingDB = bCombatStance ? E_KenyaMotionMatchingDB::Combat : E_KenyaMotionMatchingDB::Normal;
- CurrentCHT = bCombatStance ? CombatCHT : MainCHT;
- break;
- case EOverlayState::Scan:
- MotionMatchingDB = E_KenyaMotionMatchingDB::Psyche;
- CurrentCHT = PsycheCHT;
- break;
- case EOverlayState::Minigun:
- MotionMatchingDB = E_KenyaMotionMatchingDB::Minigun;
- CurrentCHT = MiniGunCHT;
- break;
- }
- }
- void USDKenyaAnimInstance::UpdatePullPushValues(const float DeltaSeconds)
- {
- bIsPulling = Proxy.Character->GetAbilitySystemComponent()->HasMatchingGameplayTag(FGameplayTag::RequestGameplayTag(FName("Ability.Combat.Pull")));
- }
- void USDKenyaAnimInstance::UpdateBeamWalkValues(const float DeltaSeconds)
- {
- if (!Proxy.Character->BeamComponent)
- return;
- bEnableBeamWalk = Proxy.Character->BeamComponent->bBeamWalkEnable;
- bBeamWobble = Proxy.Character->BeamComponent->bAtEndOfBeam;
- }
- FTransform USDKenyaAnimInstance::GetInteractionTransform() const
- {
- return InteractionTransform;
- }
- void USDKenyaAnimInstance::SetInteractionTransform(FTransform SetTransform)
- {
- InteractionTransform=SetTransform;
- }
- void USDKenyaAnimInstance::GenerateTrajectory(const float DeltaSeconds)
- {
- UPoseSearchTrajectoryLibrary::PoseSearchGenerateTrajectory(this, Speed2D > 0 ? TrajectoryGenerationData_Moving : TrajectoryGenerationData_Idle,
- DeltaSeconds, Trajectory, PreviousDesiredControllerYaw,Proxy.OutTrajectory, -1.0,
- 30,0.071,15 );
- // collison check is causing incorrect jump mechanics for climbing
- UPoseSearchTrajectoryLibrary::HandleTrajectoryWorldCollisions(Proxy.Character.Get(), this, Proxy.OutTrajectory, true, 0.01, Trajectory , TrajectoryCollision,
- ETraceTypeQuery::TraceTypeQuery1, false, EmptyArray, EDrawDebugTrace::None,true, 150);
- UPoseSearchTrajectoryLibrary::GetTrajectorySampleAtTime(Trajectory,0.5, Proxy.OutTrajectorySample1);
- UPoseSearchTrajectoryLibrary::GetTrajectorySampleAtTime(Trajectory,0.4,Proxy.OutTrajectorySample2);
- FutureVelocity = (Proxy.OutTrajectorySample1.Position - Proxy.OutTrajectorySample2.Position) * 10.0f;
- }
- void USDKenyaAnimInstance::UpdateEssentialValue(const float DeltaSeconds)
- {
- //0)
- CharacterTransformLastFrame = CharacterTransform;
- CharacterTransform = Proxy.Character->GetActorTransform();
- //1)
- bOffsetRootBoneEnabled = true; //UKismetSystemLibrary::GetConsoleVariableBoolValue("a.animnode.offsetrootbone.enable"); todo WEIRD BP CODE
- if (bOffsetRootBoneEnabled)
- {
- //UpdateRootBoneTransformFix();
- /*FRotator OffsetRotation = AnimNodeOffsetRootTransform.Rotator();
- OffsetRotation.Yaw += 90.0f;
- RootTransform = FTransform(OffsetRotation, AnimNodeOffsetRootTransform.GetLocation(), FVector(1.0f, 1.0f, 1.0f));*/
- const FTransform AnimNodeRootTransform = UAnimationWarpingLibrary::GetOffsetRootTransform(UpdateRootBoneNode);
- FRotator OffsetRotation = AnimNodeRootTransform.Rotator();
- OffsetRotation.Yaw += 90.0f;
- RootTransform = FTransform(OffsetRotation, AnimNodeRootTransform.GetLocation(), FVector(1.0f, 1.0f, 1.0f));
- } else
- {
- RootTransform = CharacterTransform;
- }
- //2)
- AccelerationLastFrame = Acceleration;
- Acceleration = Proxy.CharacterMovement->GetCurrentAcceleration();
- AccelerationAmount = Acceleration.Size() / Proxy.CharacterMovement->MaxAcceleration;
- bHasAcceleration = AccelerationAmount > 0.f;
- //3)
- VelocityLastFrame = Velocity;
- Velocity = Proxy.CharacterMovement->Velocity;
- Speed2D = Velocity.Size2D();
- bHasVelocity = Speed2D > 5.f;
- VelocityAcceleration = (Velocity - VelocityLastFrame) / DeltaSeconds;
- if (bHasVelocity) LastNonZeroVelocity = Velocity;
- //4)
- AwarenessSpineRotator = Proxy.Character->AwarenessSpineRotator;
- AwarenessSpineRotation = FMath::FInterpTo(AwarenessSpineRotation, AwarenessSpineRotator, DeltaSeconds, 4.5);//todo 6 seems to fast
- AwarenessSpineRotationNegative = AwarenessSpineRotation * -1.0;
- //5)
- if (Proxy.Character->OverlayStateN != OverlayState)
- {
- PreviousOverlayState = OverlayState;
- OverlayState = Proxy.Character->OverlayStateN;
- }
- //6)
- InputVector = Proxy.CharacterMovement->GetLastInputVector().GetClampedToSize(0, 1);
- ForwardVector = Proxy.Character->GetActorForwardVector();
- RightVector = Proxy.Character->GetActorRightVector();
- bIsOnGround = Proxy.CharacterMovement->IsMovingOnGround();
- }
- void USDKenyaAnimInstance::UpdateWallRunValues(const float DeltaSeconds) {
- if (!Proxy.Character->WallRunAbility) return;
- // Now safe to access WallRunAbility
- bIsWallRunning = Proxy.Character->WallRunAbility->bIsWallRunning;
- bIsWallJumping = Proxy.Character->WallRunAbility->bIsWallJumping;
- bIsWallRunningORJumping = bIsWallRunning || bIsWallJumping;
- bIsDoubleJump = (bIsWallRunning) ? false : bIsDoubleJump;
- bIsAirDashOrIsDoubleAirDash = (bIsWallRunning) ? false : bIsAirDashOrIsDoubleAirDash;
- bIsWallRunningNORJumping = !bIsWallRunningORJumping;
- WallSide = Proxy.Character->WallRunAbility->WallSide;
- bIsWallSideRight = WallSide == EWallRunDirection::Right;
- bIsWallSideLeft = !bIsWallSideRight;
- CurrentArcAngle = Proxy.Character->WallRunAbility->CurrentArcAngle;
- CurrentTurnRate = Proxy.Character->WallRunAbility->CurrentTurnRate;
- WallJumpHorizontalVelocity = Proxy.Character->WallRunAbility->WallJumpHorizontalVelocity;
- WallJumpVerticalVelocity = Proxy.Character->WallRunAbility->WallJumpVerticalVelocity;
- CurrentSpeed = Proxy.Character->GetVelocity().Length();
- // 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.
- WallRunAnimPlayRate = FMath::GetMappedRangeValueClamped(FVector2D(935, 1265), FVector2D(1.f, 1.3f), CurrentSpeed);
- // 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.
- WallJumpAnimationSpeed = FMath::GetMappedRangeValueClamped(FVector2D(943.f, 1500.f), FVector2D(1.0, 1.5), FVector(0, WallJumpHorizontalVelocity, WallJumpVerticalVelocity).Length());
- // 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.
- const float TargetAdditive = (CurrentArcAngle >= 15.f) ?
- FMath::GetMappedRangeValueClamped(FVector2D(30.f,45.f), FVector2D(1.f, 0.f), CurrentArcAngle) :
- FMath::GetMappedRangeValueClamped(FVector2D(0.f, 30.f), FVector2d(0.0f, 1.f), CurrentArcAngle);
- HandCorrectionAdditive = FMath::FInterpTo(HandCorrectionAdditive, TargetAdditive, DeltaSeconds, 7.f);
- }
- void USDKenyaAnimInstance::UpdateFreeClimbValues(const float DeltaSeconds)
- {
- //Update Free Climb Transition Bools
- bIsFreeClimbing = Proxy.CharacterMovement->IsFreeClimbing();
- bIsFreeClimbingOnCeiling = Proxy.CharacterMovement->IsFreeClimbOnCeiling();
- bIsFreeClimbDashing = Proxy.CharacterMovement->IsFreeClimbDashing();
- bIsFreeClimbTurningCorner = Proxy.CharacterMovement->bIsTurningCorner;
- bIsFreeClimbSwinging = Proxy.CharacterMovement->IsSwinging();
- bIsFreeClimbSwingLeaping = Proxy.CharacterMovement->IsSwingLeaping();
- bIsFreeClimbOnEdge = Proxy.CharacterMovement->IsAtEdge();
- bFreeClimbTurnAround = Proxy.CharacterMovement->ShouldTurnAround();
- bIsFreeClimbingOnWall = bIsFreeClimbing && !bIsFreeClimbingOnCeiling;
- bFreeClimbEnterFromTop = Proxy.CharacterMovement->EnteredClimbFromTop();
- FreeClimbTrueBlendValue = bFreeClimbEnterFromTop ? 0.0f : 0.2f;
- FreeClimbSpeed = Proxy.CharacterMovement->GetFreeClimbMaxSpeed();
- FreeClimbCeilingSpeed = Proxy.CharacterMovement->GetCeilingFreeClimbMaxSpeed();
- Proxy.CharacterMovement->GetTurningType(bFreeClimbTurnRight, bFreeClimbTurnInner);
- FreeClimbIKAlpha = GetCurveValue(FName("EnableFreeClimbIK"));
- bFreeClimbToDashBackup = bIsFreeClimbDashing && !bIsFreeClimbTurningCorner && bUsedClimbDashBackup;
- bFreeClimbToDash = bIsFreeClimbDashing && !bIsFreeClimbTurningCorner && !bUsedClimbDashBackup;
- bFreeClimbToTurnCorner = bIsFreeClimbDashing && bIsFreeClimbTurningCorner;
- //Update FreeClimbFrom
- if (!bIsFreeClimbing)
- {
- bCheckedFreeClimbFrom = false;
- return;
- }
- if (!bCheckedFreeClimbFrom)
- {
- FreeClimbFrom = MovementMode_LastFrame;
- bCheckedFreeClimbFrom = true;
- }
- //Update FreeClimbDashVelocity
- const FVector UnrotatedDashVec = Proxy.Character->GetActorRotation().UnrotateVector(Proxy.CharacterMovement->GetFreeClimbDashDirection());
- if (bIsFreeClimbingOnCeiling)
- FreeClimbDashVelocity = FVector2D(UnrotatedDashVec.Y, UnrotatedDashVec.X);
- else
- FreeClimbDashVelocity = FVector2D(UnrotatedDashVec.Y, UnrotatedDashVec.Z);
- //Update FreeClimbDirection
- FreeClimbInput = FVector2D(Proxy.Character->MoveRightInputRawValue, Proxy.Character->MoveForwardInputRawValue);
- const FVector UnrotatedVelVec = Proxy.Character->GetActorRotation().UnrotateVector(Proxy.CharacterMovement->Velocity);
- FVector2D FreeClimbVelocity;
- if (bIsFreeClimbingOnCeiling)
- FreeClimbVelocity = FVector2D(UnrotatedVelVec.X, UnrotatedVelVec.Y) * 0.0083f;
- else
- FreeClimbVelocity = FVector2D(UnrotatedVelVec.Y, UnrotatedVelVec.Z) * 0.0083f;
- const bool bHasTag = Proxy.Character->GetAbilitySystemComponent()->HasMatchingGameplayTag(FGameplayTag::RequestGameplayTag(FName("AbilityEvent.Character.FreeClimb.Enter")));
- if (FreeClimbVelocity.Length() < 0.01f || bHasTag)
- FreeClimbInput = FVector2D::ZeroVector;
- bFreeClimbNotMoving = FreeClimbInput.Length() <= 0.0f;
- /*bIsFreeClimbing = Proxy.Character->SDCharacterMovementComponent->IsFreeClimbing();
- bIsFreeClimbingOnCeiling = Proxy.Character->SDCharacterMovementComponent->IsFreeClimbOnCeiling();
- bIsFreeClimbDashing = Proxy.Character->SDCharacterMovementComponent->IsFreeClimbDashing();
- bIsFreeClimbTurningCorner = Proxy.Character->SDCharacterMovementComponent->bIsTurningCorner;
- bIsFreeClimbSwinging = Proxy.Character->SDCharacterMovementComponent->IsSwinging();
- bIsFreeClimbSwingLeaping = Proxy.Character->SDCharacterMovementComponent->IsSwingLeaping();
- bIsFreeClimbOnEdge = Proxy.Character->SDCharacterMovementComponent->IsAtEdge();
- bFreeClimbTurnAround = Proxy.Character->SDCharacterMovementComponent->ShouldTurnAround();
- bIsFreeClimbingOnWall = bIsFreeClimbing && !bIsFreeClimbingOnCeiling;
- bFreeClimbEnterFromTop = Proxy.Character->SDCharacterMovementComponent->EnteredClimbFromTop();
- FreeClimbTrueBlendValue = bFreeClimbEnterFromTop ? 0.0f : 0.2f;
- FreeClimbSpeed = Proxy.Character->SDCharacterMovementComponent->GetFreeClimbMaxSpeed();
- FreeClimbCeilingSpeed = Proxy.Character->SDCharacterMovementComponent->GetCeilingFreeClimbMaxSpeed();
- Proxy.Character->SDCharacterMovementComponent->GetTurningType(bFreeClimbTurnRight, bFreeClimbTurnInner);
- FreeClimbIKAlpha = GetCurveValue(FName("EnableFreeClimbIK"));
- bFreeClimbToDashBackup = bIsFreeClimbDashing && !bIsFreeClimbTurningCorner && bUsedClimbDashBackup;
- bFreeClimbToDash = bIsFreeClimbDashing && !bIsFreeClimbTurningCorner && !bUsedClimbDashBackup;
- bFreeClimbToTurnCorner = bIsFreeClimbDashing && bIsFreeClimbTurningCorner;
- //Update FreeClimbFrom
- if (!bIsFreeClimbing)
- {
- bCheckedFreeClimbFrom = false;
- return;
- }
- if (!bCheckedFreeClimbFrom)
- {
- FreeClimbFrom = MovementMode_LastFrame;
- bCheckedFreeClimbFrom = true;
- }
- //Update FreeClimbDashVelocity
- const FVector UnrotatedDashVec = Proxy.Character->GetActorRotation().UnrotateVector(Proxy.Character->SDCharacterMovementComponent->GetFreeClimbDashDirection());
- if (bIsFreeClimbingOnCeiling)
- FreeClimbDashVelocity = FVector2D(UnrotatedDashVec.Y, UnrotatedDashVec.X);
- else
- FreeClimbDashVelocity = FVector2D(UnrotatedDashVec.Y, UnrotatedDashVec.Z);
- //Update FreeClimbDirection
- FreeClimbInput = FVector2D(Proxy.Character->MoveRightInputRawValue, Proxy.Character->MoveForwardInputRawValue);
- const FVector UnrotatedVelVec = Proxy.Character->GetActorRotation().UnrotateVector(Proxy.CharacterMovement->Velocity);
- FVector2D FreeClimbVelocity;
- if (bIsFreeClimbingOnCeiling)
- FreeClimbVelocity = FVector2D(UnrotatedVelVec.X, UnrotatedVelVec.Y) * 0.0083f;
- else
- FreeClimbVelocity = FVector2D(UnrotatedVelVec.Y, UnrotatedVelVec.Z) * 0.0083f;
- const bool bHasTag = Proxy.Character->GetAbilitySystemComponent()->HasMatchingGameplayTag(FGameplayTag::RequestGameplayTag(FName("AbilityEvent.Character.FreeClimb.Enter")));
- if (FreeClimbVelocity.Length() < 0.01f || bHasTag)
- FreeClimbInput = FVector2D::ZeroVector;
- FreeClimbInput = FVector2D::Zero();
- bFreeClimbNotMoving = FreeClimbInput.Length() <= 0.0f;*/
- }
- void USDKenyaAnimInstance::UpdateSlideValues(const float DeltaSeconds)
- {
- bIsSlidingDown = Proxy.Character->bIsSlidingDown;
- SlidingDownFalseBlendValue = 0.2f;
- SlideType = Proxy.Character->SlideType;
- if (!Proxy.CharacterMovement->IsFalling() || bIsDoubleJump)
- bWasSliding = false;
- const AActor* Floor = Proxy.CharacterMovement->CurrentFloor.HitResult.GetActor();
- if (Floor)
- {
- FloorActorTags = Floor->Tags;
- bWasSliding = bIsSlidingDown;
- SlidePitch = Proxy.CharacterMovement->CurrentFloor.HitResult.Normal.ToOrientationRotator().Pitch - 60.0f;
- }
- bIsSlidingOrSlideJumping = bIsSlidingDown || (bWasSliding && Velocity.Z > 0.0f);
- }
- void USDKenyaAnimInstance::UpdateStates()
- {
- //0
- MovementMode_LastFrame = MovementMode;
- switch (Proxy.CharacterMovement->MovementMode)
- {
- case MOVE_None:
- case MOVE_Walking:
- case MOVE_NavWalking:
- MovementMode = EMM_MovementMode::OnGround;
- break;
- case MOVE_Falling:
- MovementMode = EMM_MovementMode::InAir;
- if (MovementMode_LastFrame == EMM_MovementMode::OnGround)
- {
- PreviousGroundedGait = Gait;
- }
- break;
- case MOVE_Swimming:
- case MOVE_Flying:
- case MOVE_Custom:
- case MOVE_MAX:
- default:
- break;
- }
- //1
- RotationMode_LastFrame = RotationMode;
- Proxy.CharacterMovement->bOrientRotationToMovement ? RotationMode = EMM_RotationMode::OrientToMovement : RotationMode = EMM_RotationMode::Strafe;
- //2
- MovementState_LastFrame = MovementState;
- IsMovingUpdate();
- bIsMoving ? MovementState = EMM_MovementState::Moving : MovementState = EMM_MovementState::Idle;
- //3
- Gait_LastFrame = Gait;
- Gait = Proxy.Character->Gait;
- switch (Proxy.Character->Gait)//Weird
- {
- case EMM_Gait::Walk:
- Gait = EMM_Gait::Walk;
- break;
- case EMM_Gait::Run:
- Gait = EMM_Gait::Run;
- break;
- case EMM_Gait::Sprint:
- Gait = EMM_Gait::Sprint;
- break;
- }
- //4
- Stance_LastFrame = Stance;
- Proxy.CharacterMovement->IsCrouching() ? Stance = EMM_Stance::Crouch : Stance = EMM_Stance::Stand;
- }
- ///AnimGraph
- #pragma region AnimGraph
- float USDKenyaAnimInstance::Get_OffsetRootTranslationHalfLife() const
- {
- switch (MovementState)
- {
- case EMM_MovementState::Idle:
- return 0.2;
- case EMM_MovementState::Moving:
- return 0.1;
- }
- return 0;
- }
- FFootPlacementInterpolationSettings USDKenyaAnimInstance::Get_FootPlacementInterpolationSettings() const
- {
- return CurrentDatabaseTags.Contains(FName("Stops")) ? InterpolationSettings_Stops : InterpolationSettings_Default;
- }
- FFootPlacementPlantSettings USDKenyaAnimInstance::Get_FootPlacementPlantSettings() const
- {
- return CurrentDatabaseTags.Contains(FName("Stops")) ? PlantSettings_Stops : PlantSettings_Default;
- }
- EOffsetRootBoneMode USDKenyaAnimInstance::Get_OffsetRootTranslationMode() const
- {
- if ( IsSlotActive(FName("DefaultSlot")) )
- {
- return EOffsetRootBoneMode::Release;
- }
- switch (MovementMode)
- {
- case EMM_MovementMode::OnGround:
- return bIsMoving ? EOffsetRootBoneMode::Interpolate : EOffsetRootBoneMode::Release;
- case EMM_MovementMode::InAir:
- return EOffsetRootBoneMode::Release;
- }
- return EOffsetRootBoneMode::Accumulate;
- }
- EOffsetRootBoneMode USDKenyaAnimInstance::Get_OffsetRootRotationMode() const
- {
- if (bAllowImmediateRotation or IsSlotActive(FName("DefaultSlot")) or bIsADS or bEnableBeamWalk)
- {
- return EOffsetRootBoneMode::Release;
- }
- if (RotationMode == EMM_RotationMode::Strafe)
- {
- FRotator Delta = Character->GetControlRotation() - RootTransform.Rotator();
- Delta.Normalize();
- return FMath::Abs(Delta.Yaw) > 25.0 ? EOffsetRootBoneMode::Interpolate : EOffsetRootBoneMode::Release;
- }
- return EOffsetRootBoneMode::Accumulate;
- }
- bool USDKenyaAnimInstance::IsMoving() const
- {
- constexpr float Threshold = 0.1f;
- return !Velocity.Equals( FVector::ZeroVector, Threshold) && !FutureVelocity.Equals( FVector::ZeroVector, Threshold);
- }
- float USDKenyaAnimInstance::Get_MMBlendTimeUpdate() const
- {
- switch (MovementMode) {
- case EMM_MovementMode::OnGround:
- //if ((PreviousGroundedGait == EMM_Gait::Run or PreviousGroundedGait == EMM_Gait::Sprint) && Gait == EMM_Gait::Walk){return 0.4f;}
- switch (MovementMode_LastFrame)
- {
- case EMM_MovementMode::OnGround:
- return 0.4f;
- case EMM_MovementMode::InAir:
- return 0.2f;
- }
- break;
- case EMM_MovementMode::InAir:
- if (Velocity.Z > 100.0f)
- {
- return 0.15f;
- }
- return 0.5f;
- }
- return 0;
- }
- float USDKenyaAnimInstance::Get_MMNotifyRecencyTimeoutUpdate() const
- {
- switch (Gait)
- {
- case EMM_Gait::Walk:
- return 0.2f;
- case EMM_Gait::Run:
- return 0.2f;
- case EMM_Gait::Sprint:
- return 0.16f;
- }
- return 0;
- }
- EPoseSearchInterruptMode USDKenyaAnimInstance::Get_MMInterrupt() const
- {
- 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 )
- ? EPoseSearchInterruptMode::InterruptOnDatabaseChange : EPoseSearchInterruptMode::DoNotInterrupt;
- }
- void USDKenyaAnimInstance::Update_MotionMatchingDBS(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
- {
- EAnimNodeReferenceConversionResult Result{};
- const FMotionMatchingAnimNodeReference MM = UMotionMatchingAnimNodeLibrary::ConvertToMotionMatchingNode(Node, Result);
- //if (Result == EAnimNodeReferenceConversionResult::Failed) return; Unsafe
- //UPoseSearchDatabase* DB = Cast<UPoseSearchDatabase>(UChooserFunctionLibrary::EvaluateChooser(this, LocomotionTable, UPoseSearchDatabase::StaticClass())); FOR SIngle Database
- TArray<UObject*> RawResults = UChooserFunctionLibrary::EvaluateChooserMulti(this, CurrentCHT, UPoseSearchDatabase::StaticClass());
- TArray<UPoseSearchDatabase*> Databases;
- Databases.Reserve(RawResults.Num());
- for (UObject* Obj : RawResults)
- {
- Databases.Add(Cast<UPoseSearchDatabase>(Obj)); //No safety check for performance reasons
- }
- UMotionMatchingAnimNodeLibrary::SetDatabasesToSearch(MM, Databases, Get_MMInterrupt());
- //LOG_THREAD_LOCATION(0.01,"Update_MotionMatchingDBS");
- //Update other AnimGraph variables
- IsMovingUpdate();
- }
- void USDKenyaAnimInstance::Update_MotionMatchingPostSelection(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
- {
- if (!CurrentSelectedDatabase.Get() ) return;
- EAnimNodeReferenceConversionResult Result{};
- const FMotionMatchingAnimNodeReference MM = UMotionMatchingAnimNodeLibrary::ConvertToMotionMatchingNode(Node, Result);
- //if (Result == EAnimNodeReferenceConversionResult::Failed) return;unsafe for perf
- FPoseSearchBlueprintResult OutResult;
- bool bIsValidResult;
- UMotionMatchingAnimNodeLibrary::GetMotionMatchingSearchResult(MM, OutResult, bIsValidResult);
- CurrentSelectedDatabase = OutResult.SelectedDatabase;
- }
- FVector2D USDKenyaAnimInstance::Get_LeanAmount() const
- {
- const float LeanMultiplier = FMath::GetMappedRangeValueClamped(FVector2D(150.0f, 350.0f), FVector2D(0.5f, 1.0f), Speed2D);
- // Apply to X component (forward/backward acceleration)
- return FVector2D( CalculateRelativeAccelerationAmount().X * LeanMultiplier, 0.0f);
- }
- FVector USDKenyaAnimInstance::CalculateRelativeAccelerationAmount() const
- {
- if (!CharacterMovement) return FVector::Zero();
- if ( CharacterMovement->MaxAcceleration > 0.0f && CharacterMovement->GetMaxBrakingDeceleration() > 0.0f )
- {
- if ( FVector::DotProduct(Velocity, Acceleration) > 0.0f )
- {
- return CharacterTransform.Rotator().UnrotateVector(VelocityAcceleration.GetClampedToMaxSize(CharacterMovement->GetMaxAcceleration()) / CharacterMovement->MaxAcceleration);
- }
- const FVector A = VelocityAcceleration.GetClampedToMaxSize(CharacterMovement->MaxAcceleration) / CharacterMovement->GetMaxAcceleration();
- return CharacterTransform.Rotator().UnrotateVector(A);
- }
- return FVector(0.0f);
- }
- #pragma endregion;
- #pragma region Delegates
- void USDKenyaAnimInstance::OnLandingEventReceived(FGameplayEventData Payload)
- {
- bLocomotionLanded = true;
- bIsDoubleJump = false;
- bIsAirDash = false;
- //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
- const FHitResult TargetDataHit = [&]() -> FHitResult
- {
- const auto& TD = Payload.TargetData;
- if (TD.Data.IsValidIndex(0))
- {
- if (FGameplayAbilityTargetData* DataPtr = TD.Data[0].Get())
- {
- if (const FHitResult* HitPtr = DataPtr->GetHitResult())
- {
- return *HitPtr;
- }
- }
- }
- // fallback if there was no valid hit
- return FHitResult();
- }();
- //LandVelocity = TargetDataHit.Normal;
- LandVelocity = CharacterMovement->Velocity;
- const AActor* Floor = TargetDataHit.GetActor();
- if (Floor)
- {
- FloorActorTags = Floor->Tags;
- }
- //LandVelocity = UAbilitySystemBlueprintLibrary::GetHitResultFromTargetData(Payload.TargetData, 0).Normal;
- FTimerManager& TimerManager = Character->CachedWorld->GetTimerManager();
- TimerManager.ClearTimer(LandingResetTimerHandle);
- TimerManager.SetTimer(LandingResetTimerHandle,
- FTimerDelegate::CreateWeakLambda(this, [this]()
- {
- bLocomotionLanded = false;
- bLandFromDoubleJump = false;
- bLandFromAirDash = false;
- }),0.2f, false );
- if (!JustLandedSprintingDoubleJump())
- {
- JustLandedHeavyUpdate();
- if (bJustLandedHeavy) {
- if (CanRunOnce())
- {
- FOnMontageBlendingOutStarted BlendOutDelegate;
- BlendOutDelegate.BindUObject(this, &ThisClass::HardLandingOnRollMontageBlendOut);
- Montage_Play(LandRollMontage, 1.0f);
- Montage_SetBlendingOutDelegate(BlendOutDelegate, LandRollMontage);
- }
- }
- }
- }
- void USDKenyaAnimInstance::TaskTestTiming_Implementation()
- {
- }
- void USDKenyaAnimInstance::HardLandingOnRollMontageBlendOut(UAnimMontage* Montage, bool bInterrupted)
- {
- CharacterMovement->StopMovementImmediately();
- bHasRun = false;
- }
- bool USDKenyaAnimInstance::JustLandedSprintingDoubleJump() const
- {
- return bLandFromDoubleJump && bLocomotionLanded && (PreviousGroundedGait == EMM_Gait::Sprint or Gait == EMM_Gait::Sprint);
- }
- void USDKenyaAnimInstance::ChangeMMInterruptToTrue()
- {
- bChangeMotionMatchingDBGet_MMInterruptNow=true;
- GetWorld()->GetTimerManager().SetTimer(TimerHandleInterruptToTrue, this, &USDKenyaAnimInstance::ChangeMMInterruptToTrueNow, 0.1f, false);
- }
- void USDKenyaAnimInstance::ChangeMMInterruptToTrueNow()
- {
- bChangeMotionMatchingDBGet_MMInterruptNow=false;
- }
- void USDKenyaAnimInstance::CoversystemMovingCheckUpdate()
- {
- if LIKELY(CharacterMovement->IsValidLowLevelFast())
- {
- bIsMovingNow = CharacterMovement->Velocity.Length()>0;
- }
- }
- void USDKenyaAnimInstance::StartTimerCover()
- {
- float TimerDelay = 0.003f; // Set timer delay to 1 second
- GetWorld()->GetTimerManager().SetTimer(TimerHandleCoverStart, this, &USDKenyaAnimInstance::CoversystemMovingCheckUpdate, TimerDelay, true);
- GEngine->AddOnScreenDebugMessage(-1, 2.f,FColor::Blue, TEXT("-----move tiemr start-----"));
- }
- void USDKenyaAnimInstance::StopTimerCover()
- {
- GetWorld()->GetTimerManager().ClearTimer(TimerHandleCoverStart);
- }
- void USDKenyaAnimInstance::IdleAimOffsetYawPitchUpdate(float DeltaTime)
- {
- if (OverlayState==EOverlayState::Unarmed&&MovementState==EMM_MovementState::Idle&&MovementMode==EMM_MovementMode::OnGround&&Speed2D<20&&bJustLandedLight==false&&bJustLandedHeavy==false)
- {
- UseIdleAimOffset=true;
- }
- else
- {
- UseIdleAimOffset=false;
- return;
- }
- const float YawCacheMovement = Character->GetCapsuleComponent()->GetComponentRotation().Yaw;
- const float YawCache = Character->GetControlRotation().Yaw;
- float YawOriginal = YawCache-YawCacheMovement;
- float PitchOriginal = FRotator::NormalizeAxis(TryGetPawnOwner()->GetBaseAimRotation().Pitch);
- float YawSpeedMultiplier = 2.5f;
- float PitchSpeedMultiplier = 2.5f;
- YawOriginal = (YawOriginal > 180.0f) ? (YawOriginal - 360.0f) : YawOriginal;
- if (FMath::Abs(YawOriginal)>130.0f)
- {
- YawOriginal=0;
- PitchOriginal = 0;
- YawSpeedMultiplier=1.5f;
- PitchSpeedMultiplier=1.5f;
- }
- YawOriginal = FMath::Clamp(YawOriginal, -90.0f, 90.0f);
- PitchOriginal = FMath::Clamp(PitchOriginal, -70.0f, 70.0f);
- IdleAimOffsetYaw=FMath::Lerp(IdleAimOffsetYaw, YawOriginal, DeltaTime*YawSpeedMultiplier);
- IdleAimOffsetPitch=FMath::Lerp(IdleAimOffsetPitch, PitchOriginal, DeltaTime*PitchSpeedMultiplier);
- }
- void USDKenyaAnimInstance::ShockFirePawPitchUpdate()
- {
- //for pitch
- if UNLIKELY(!Character)
- {
- return;
- }
- float PitchCache = Character->GetControlRotation().Pitch;
- constexpr float TimeMultiplier = 4.0f;
- PitchCache = (PitchCache > 180.0f) ? (PitchCache - 360.0f) : PitchCache;
- ShockPitch=FMath::Lerp(ShockPitch, PitchCache, 0.001f * TimeMultiplier);
- //FQuat DeltaRotation = EndRotation.Inverse() * StartRotation;
- const FQuat StartRotation = Character->GetCapsuleComponent()->GetComponentRotation().Quaternion(); // Initial rotation (e.g., the start state)
- const FQuat EndRotation = Character->GetControlRotation().Quaternion(); // End rotation (90 degrees on the Z axis)
- //FQuat DeltaRotation = EndRotation.Inverse() * StartRotation;
- const FQuat DeltaRotation = StartRotation.Inverse() * EndRotation;
- //yawOriginal=delta.Yaw;
- float YawOriginal = DeltaRotation.Rotator().Yaw;
- YawOriginal = (YawOriginal > 180.0f) ? (YawOriginal - 360.0f) : YawOriginal;
- YawOriginal = FMath::Clamp(YawOriginal, -150.0f, 150.0f);;
- ShockYaw = FMath::Lerp(ShockYaw, YawOriginal, 0.001f*TimeMultiplier);
- ///
- ///Aim Offset
- if (bIsSlidingDown) {
- // Use right hand when sliding and turning towards left (when right hand is up)
- ShockFireUseRightHand = (InputVector.X < -0.5f);
- }
- else if (ShockYaw > 0 != ShockFireUseRightHand && !psycheScanNoUseRightHandNow)
- {
- ShockFireUseRightHand=ShockYaw>0;
- if (bUseShockFire)
- {
- Character->OverlayStateN=EOverlayState::Unarmed;
- // Set the timer to call TimerFunction after 0.01 second
- //GetWorld()->GetTimerManager().SetTimer(TimerHandleShockAOScan, this, &USDKenyaAnimInstance::ShockFireAOchangeStateScanBack, 0.01f, false);
- }
- }
- /*if (psycheScanNoUseRightHandNow)
- {
- Character->OverlayStateN=EOverlayState::Unarmed;
- }*/
- }
- void USDKenyaAnimInstance::ShockFireAOchangeStateScanBack()
- {
- Character->OverlayStateN=EOverlayState::Scan;
- }
- void USDKenyaAnimInstance::SetStateShockFireAimOfsett(bool start)
- {
- if (bUseShockFire==start)
- {
- return;
- }
- bUseShockFire=start;
- if (start)
- {
- GetWorld()->GetTimerManager().SetTimer(TimerHandleStateShockFireAimOfsett, this, &USDKenyaAnimInstance::ShockFirePawPitchUpdate, 0.001f, true);
- }
- else
- {
- GetWorld()->GetTimerManager().ClearTimer(TimerHandleStateShockFireAimOfsett);
- }
- }
- void USDKenyaAnimInstance::idleTurnInplaceTick()
- {
- FRotator RMesh = GetSkelMeshComponent()->GetSocketRotation(FName("rootSocket"));
- FQuat QuatA = FQuat(RMesh);
- FQuat QuatB = FQuat(TryGetPawnOwner()->GetActorRotation());
- // Calculate the difference (delta) as a quaternion
- FQuat DeltaQuat = QuatA.Inverse() * QuatB;
- // Convert the delta quaternion back to a rotator
- FRotator DeltaRotation = DeltaQuat.Rotator();
- if (FMath::Abs(DeltaRotation.Yaw) > 45&&Speed2D<100)
- {
- idleTurnInplace = true;
- }
- else
- {
- idleTurnInplace = false;
- }
- }
- void USDKenyaAnimInstance::StartMinigunShooting(bool startShootingAimOffset)
- {
- bMinigunActive=startShootingAimOffset;
- if (startShootingAimOffset)
- {
- GetWorld()->GetTimerManager().SetTimer(MyTimerHandle, this, &USDKenyaAnimInstance::PlayerPitchUpdate, 0.033f, true);
- }
- else
- {
- GetWorld()->GetTimerManager().ClearTimer(MyTimerHandle);
- }
- }
- void USDKenyaAnimInstance::PlayerPitchUpdate()
- {
- //GEngine->AddOnScreenDebugMessage(-1, 2.f,FColor::Blue, TEXT("-----MOVE FORWARD Activeeeeeeee -----"));
- pitchMinigun=TryGetPawnOwner()->GetControlRotation().Pitch;
- if (pitchMinigun>180.0f)
- {
- pitchMinigun-=360.0f;
- }
- pitchMinigun+=15.0f;
- }
- void USDKenyaAnimInstance::SetRootYawOffset1(float InRootYawOffset)
- {
- RootYawOffset1=FMath::ClampAngle(UKismetMathLibrary::NormalizeAxis(InRootYawOffset),RootYawOffsetAngleClamp.X,RootYawOffsetAngleClamp.Y);
- }
- void USDKenyaAnimInstance::ProcessTurnYawCurve()
- {
- PreviousTurnYawCurveValue=TurnYawCurveValue;
- if (FMath::IsNearlyEqual(GetCurveValue(TEXT("TNT_TurnYawWeight")),0.0f, 0.0001f))
- {
- TurnYawCurveValue=0;
- PreviousTurnYawCurveValue=0;
- }
- else
- {
- TurnYawCurveValue=GetCurveValue(TEXT("TNT_TurnYaw"))/GetCurveValue(TEXT("TNT_TurnYawWeight"));
- if (PreviousTurnYawCurveValue!=0)
- {
- SetRootYawOffset1(RootYawOffset1-(TurnYawCurveValue-PreviousTurnYawCurveValue));
- }
- }
- PreviousTurnYawCurveValue=0;
- }
- void USDKenyaAnimInstance::UpdateRootYawOffset(float InDeltaTime)
- {
- SetRootYawOffset1(RootYawOffset1-YawDeltaSinceLastUpdate2);
- IsFirstUpdate=false;
- }
- void USDKenyaAnimInstance::UpdateIdleState(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
- {
- //EAnimNodeReferenceConversionResult
- EAnimNodeReferenceConversionResult ConvR1;
- FAnimationStateResultReference State1;
- UAnimationStateMachineLibrary::ConvertToAnimationStateResult(Node,State1,ConvR1);
- if (UAnimationStateMachineLibrary::IsStateBlendingOut(Context,State1))
- {
- TurnYawCurveValue=0;
- }
- {
- ProcessTurnYawCurve();
- }
- }
- void USDKenyaAnimInstance::UpdateRotationData()
- {
- YawDeltaSinceLastUpdate2=GetOwningActor()->GetActorRotation().Yaw-WorldRotation.Yaw;
- WorldRotation=GetOwningActor()->GetActorRotation();
- if (IsFirstUpdate)
- {
- YawDeltaSinceLastUpdate2=0;
- }
- }
- void USDKenyaAnimInstance::SetupTurnInPlaceAnim(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
- {
- TurnInPlaceAnimTime=0;
- EAnimNodeReferenceConversionResult Result1;
- USequenceEvaluatorLibrary::SetExplicitTime(USequenceEvaluatorLibrary::ConvertToSequenceEvaluator(Node,Result1),0.0f);
- }
- UAnimSequence* USDKenyaAnimInstance::SelectTurnInPlaceAnimation(float Direction)
- {
- if (Direction>0)
- {
- return TurninPlaceRight;
- }
- return TurninPlaceLeft;
- }
- void USDKenyaAnimInstance::UpdateTurnInPlaceAnim(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
- {
- EAnimNodeReferenceConversionResult Result1;
- USequenceEvaluatorLibrary::SetSequenceWithInertialBlending(Context,USequenceEvaluatorLibrary::ConvertToSequenceEvaluator(Node,Result1),SelectTurnInPlaceAnimation(TurninPlaceRotationDirection),0.2f);
- TurnInPlaceAnimTime=UAnimExecutionContextLibrary::GetDeltaTime(Context)+TurnInPlaceAnimTime;
- USequenceEvaluatorLibrary::SetExplicitTime(USequenceEvaluatorLibrary::ConvertToSequenceEvaluator(Node,Result1),TurnInPlaceAnimTime);
- }
- void USDKenyaAnimInstance::SetUpTurnInPlaceRotationState(const FAnimUpdateContext& Context,
- const FAnimNodeReference& Node)
- {
- TurninPlaceRotationDirection=FMath::Sign(RootYawOffset1)*-1.0f;
- }
- /*void USDKenyaAnimInstance::SetUpTurnInPlaceRecoveryState(const FAnimUpdateContext& Context,
- const FAnimNodeReference& Node)
- {
- }*/
- void USDKenyaAnimInstance::UpdateTurnInPlaceRecoveryAnim(const FAnimUpdateContext& Context,
- const FAnimNodeReference& Node)
- {
- EAnimNodeReferenceConversionResult Result1;
- USequencePlayerLibrary::SetSequenceWithInertialBlending(Context,USequencePlayerLibrary::ConvertToSequencePlayer(Node,Result1),SelectTurnInPlaceAnimation(TurninPlaceRotationDirection),0.2f);
- }
- void USDKenyaAnimInstance::OnStateEntry(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
- {
- TurnInPlaceAnimTime=0;
- TurninPlaceRotationDirection=FMath::Sign(RootYawOffset1)*-1.0f;
- }
- void USDKenyaAnimInstance::OnStateFullyBlendedIn_0(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
- {
- TurnInPlaceAnimTime=0;
- }
- /*void USDKenyaAnimInstance::OnStateFullyBlendedOut(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
- {
- }*/
- void USDKenyaAnimInstance::OnFreeClimbBecomeRelevant(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
- {
- bUsedClimbDashBackup = !bUsedClimbDashBackup;
- }
- /*
- bool USDKenyaAnimInstance::JustLanded_Heavy() const
- {
- return bLocomotionLanded && FMath::Abs(LandVelocity.Z) >= FMath::Abs(HeavyLandSpeedThreshold);
- }
- bool USDKenyaAnimInstance::JustLanded_Light() const
- {
- return bLocomotionLanded && FMath::Abs(LandVelocity.Z) < FMath::Abs(HeavyLandSpeedThreshold);
- }
- */
- bool USDKenyaAnimInstance::IsPivoting() const
- {
- //if (FutureVelocity.IsNearlyZero() || Velocity.IsNearlyZero()) return false;
- //return FMath::Abs( UKismetMathLibrary::NormalizedDeltaRotator(FutureVelocity.ToOrientationRotator(), Velocity.ToOrientationRotator()).Yaw ) >= (RotationMode == EMM_RotationMode::OrientToMovement ? 60.f : 40.f);
- FRotator Delta = FutureVelocity.ToOrientationRotator() - Velocity.ToOrientationRotator();
- Delta.Normalize();
- return FMath::Abs( Delta.Yaw ) >= (RotationMode == EMM_RotationMode::OrientToMovement ? 60.f : 40.f);
- }
- bool USDKenyaAnimInstance::IsStarting()
- {
- IsMovingUpdate();
- return bIsMoving && (FutureVelocity.Size2D() >= Velocity.Size2D()+100) && !CurrentDatabaseTags.Contains(FName("Pivots"));
- }
- void USDKenyaAnimInstance::OnJumpDoubleTaskReceived(FGameplayEventData Payload)
- {
- //GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, TEXT("!"));
- const FVector LastInputVector = CharacterMovement->GetLastInputVector();
- if (!LastInputVector.IsNearlyZero(0.0001))
- {
- CharacterMovement->bOrientRotationToMovement = false;
- Character->SetActorRotation(LastInputVector.ToOrientationRotator());
- }
- bIsDoubleJump = true;
- bLandFromDoubleJump = true;
- bIsDoubleJumpStart = true;
- FTimerManager& TimerManager = Character->CachedWorld->GetTimerManager();
- TimerManager.ClearTimer(DoubleJumpTimerHandle);
- TimerManager.SetTimer(DoubleJumpTimerHandle,
- FTimerDelegate::CreateWeakLambda(this, [this]()
- {
- bIsDoubleJumpStart = false;
- CharacterMovement->bOrientRotationToMovement = true;
- }),0.3f, false );
- }
- void USDKenyaAnimInstance::OnAirDashTaskReceived(FGameplayEventData Payload)
- {
- bIsAirDash = true;
- bLandFromAirDash = true;
- }
- void USDKenyaAnimInstance::OnClimbBeginTaskReceived(FGameplayEventData Payload)
- {
- /*Todo Implement Interface for this function to work
- *if (Payload.Target->GetClass()->ImplementsInterface(UBPI_ClimbV2::StaticClass()))
- if (TargetActor && TargetActor->GetClass()->ImplementsInterface(UBPI_ClimbV2::StaticClass()))
- {
- EClimbState ClimbType = EClimbState::Default;
- IBPI_ClimbV2::Execute_BPI_GetClimbType(TargetActor, ClimbType);
- ClimbState = ClimbType;
- OnClimbBegin();
- GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Green, TEXT("GOOD"));
- }*/
- /*AActor* TargetActor = const_cast<AActor*>(Payload.Target.Get());
- if (TargetActor && TargetActor->GetClass()->ImplementsInterface(UBPI_ClimbV2::StaticClass()))
- {
- EClimbState ClimbType = EClimbState::Default;
- IBPI_ClimbV2::Execute_BPI_GetClimbType(TargetActor, ClimbType);
- ClimbState = ClimbType;
- OnClimbBegin();
- GEngine->AddOnScreenDebugMessage(-1,10.0f, FColor::Green,TEXT("GOOD"));
- } else
- {
- GEngine->AddOnScreenDebugMessage(-1,10.0f, FColor::Green,TEXT("CONST CAST ISSUE"));
- }*/
- }
- void USDKenyaAnimInstance::OnClimbBegin()
- {
- bIsClimbing = true;
- Character->bIsClimbing = true;
- }
- void USDKenyaAnimInstance::OnClimbReachFinishedTaskReceived(FGameplayEventData Payload)
- {
- bIsClimbReaching = false;
- }
- void USDKenyaAnimInstance::OnClimbTransitionTaskReceived(FGameplayEventData Payload)
- {
- bIsClimbTransitioning = true;
- bIsClimbReaching = false;
- FTimerManager& TimerManager = Character->CachedWorld->GetTimerManager();
- TimerManager.ClearTimer(ClimbTransitionTimerHandle);
- TimerManager.SetTimer(ClimbTransitionTimerHandle,
- FTimerDelegate::CreateWeakLambda(this, [this]()
- {
- bIsClimbTransitioning = false;
- }),1.0f, false );
- }
- void USDKenyaAnimInstance::OnPerchTurnEndedTaskReceived(FGameplayEventData Payload)
- {
- if (InputMovementSpeed != FVector2D::ZeroVector)
- {
- bIsPerchTurnEnded = true;
- FTimerManager& TimerManager = Character->CachedWorld->GetTimerManager();
- TimerManager.ClearTimer(PerchTurnEndedTimerHandle);
- TimerManager.SetTimer(PerchTurnEndedTimerHandle,
- FTimerDelegate::CreateWeakLambda(this, [this]()
- {
- bIsPerchTurnEnded = false;
- }),1.0f, false);
- } else
- {
- Montage_Stop(0.2, GetCurrentActiveMontage());
- bIsPerchTurnEnded = false;
- }
- }
- void USDKenyaAnimInstance::OnStandBeginTaskReceived(FGameplayEventData Payload)
- {
- bIsClimbing = false;
- Character->bIsClimbing = false;
- }
- void USDKenyaAnimInstance::OnFreeClimbJumpTagAddedTaskReceived()
- {
- bFreeClimbJumpOff = true;
- }
- void USDKenyaAnimInstance::OnFreeClimbJumpTagRemovedTaskReceived()
- {
- bFreeClimbJumpOff = false;
- }
- #pragma endregion
- #pragma region Utilities
- #pragma endregion
- float USDKenyaAnimInstance::Get_RightLean()
- {
- if (!Character or Speed2D < KENYA_WALK_SPEED*.4 or MovementState == EMM_MovementState::Idle) return 0.f;
- if (CheckCombatStance())
- {
- switch (Gait) {
- case EMM_Gait::Walk:
- CurrentLeanBlendMontage = WalkLeanBlendMontage;
- break;
- case EMM_Gait::Run:
- CurrentLeanBlendMontage = RunLeanBlendMontage;
- break;
- case EMM_Gait::Sprint:
- CurrentLeanBlendMontage = SprintLeanBlendMontage;
- break;
- }
- } else
- {
- switch (Gait) {
- case EMM_Gait::Walk:
- CurrentLeanBlendMontage = CombatWalkLeanBlendMontage;
- break;
- case EMM_Gait::Run:
- CurrentLeanBlendMontage = CombatRunLeanBlendMontage;
- break;
- case EMM_Gait::Sprint:
- CurrentLeanBlendMontage = CombatSprintLeanBlendMontage;
- break;
- }
- }
- return CalculateRelativeAccelerationAmount().Y*UKismetMathLibrary::MapRangeClamped(Speed2D,200.0f,500.0f,0.5f,1.0f);
- //return Character->TurnRate*BlendSpaceAmount;
- /*const float DeltaSeconds = GetWorld()->GetDeltaSeconds();
- if(Gait==EMM_Gait::Walk){
- FVector2d S(Velocity.X,Velocity.Y);
- LeanTimer = FMath::Sign(Velocity.Y)!=FMath::Sign(VelocityLastFrame.Y) ?
- MaxLeanDuration : FMath::Max(0.f, LeanTimer-DeltaSeconds);
- return (S.SizeSquared()>KINDA_SMALL_NUMBER ?
- (S.Normalize(), S.Y) : 0.f)
- * (MaxLeanDuration>0.f ? LeanTimer/MaxLeanDuration : 0.f);
- }*/
- /*if ( Gait == EMM_Gait::Walk )
- {
- FVector2d Speed = FVector2d(Velocity.X, Velocity.Y);
- Speed.Normalize();
- return Speed.Y;
- }*/
- /*FVector2d Speed = FVector2d(Velocity.X, Velocity.Y);
- Speed.Normalize();*/
- //GEngine->AddOnScreenDebugMessage(-1,5.0f,FColor::Yellow,FString::Printf(TEXT("TurnRate: %f"), Proxy.Character->TurnRate*2.5));
- }
- //Blend Stack
- void USDKenyaAnimInstance::UpdateBlendStack(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
- {
- AnimTime = UBlendStackAnimNodeLibrary::GetCurrentBlendStackAnimAssetTime(Node);
- AnimAsset = UBlendStackAnimNodeLibrary::GetCurrentBlendStackAnimAsset(Node);
- const UAnimSequence* NewAnimSequence = Cast<UAnimSequence>(AnimAsset);
- //if (!NewAnimSequence) return;Unsafe
- UAnimationWarpingLibrary::GetCurveValueFromAnimation(NewAnimSequence, "Enable_OrientationWarping", AnimTime, OrientationAlpha);
- //Update Rest of Values
- IsTurningInPlaceUpdate();
- DesiredFacingUpdate();
- EnableSteeringUpdate();
- OrientationWarpingWarpingSpaceUpdate();
- }
- bool USDKenyaAnimInstance::CheckCombatStance() const
- {
- if (!Character) return false;
- return Character->GetAbilitySystemComponent()->HasMatchingGameplayTag(FGameplayTag::RequestGameplayTag(FName("Status.Combat")));
- }
- void USDKenyaAnimInstance::CheckCombatStanceV()
- {
- bCombatStance = Character->GetAbilitySystemComponent()->HasMatchingGameplayTag(FGameplayTag::RequestGameplayTag(FName("Status.Combat")));
- }
- void USDKenyaAnimInstance::UpdateOffSetRootNode(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
- {
- UpdateRootBoneNode = Node;
- }
- void USDKenyaAnimInstance::OnZiplineInitialUpdate(const FAnimUpdateContext& Context, const FAnimNodeReference& Node)
- {
- bZiplineJumpAnimEnd = false;
- }
Advertisement