4#include "Curves/CurveFloat.h"
6#include "PlayerMovementComponent.generated.h"
9UCLASS(ClassGroup = (Movement), meta = (BlueprintSpawnableComponent))
10class CK_UE_API UPlayerMovementComponent :
public UCharacterMovementComponentBase
15 UPlayerMovementComponent();
18 virtual
void TickComponent(
float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
19 virtual
void CalcVelocity(
float DeltaTime,
float Friction,
bool bFluid,
float BrakingDeceleration) override;
20 virtual
float GetMaxSpeed() const override;
23 void UpdateMovementInputRotation(const FRotator& MovementInputRotation);
26 UFUNCTION(BlueprintCallable, Category = "Pawn|Components|CharacterMovement")
27 void SetLeaningEnabled(
bool bEnabled);
29 UFUNCTION(BlueprintPure, Category = "Pawn|Components|CharacterMovement")
30 float GetRunSpeedAlpha() const;
32 UFUNCTION(BlueprintPure, Category = "Pawn|Components|CharacterMovement")
33 FORCEINLINE
float GetWalkSpeed()
const
38 UFUNCTION(BlueprintPure, Category =
"Pawn|Components|CharacterMovement")
39 FORCEINLINE
float GetRunSpeed()
const
44 UFUNCTION(BlueprintPure, Category =
"Pawn|Components|CharacterMovement")
45 FORCEINLINE
float GetCurrentMovementSpeed()
const
47 return CurrentMovementSpeed;
50 UFUNCTION(BlueprintPure, Category =
"Pawn|Components|CharacterMovement")
51 FORCEINLINE
bool IsLeaningEnabled()
const
53 return bLeaningEnabled;
56 UFUNCTION(BlueprintPure, Category =
"Pawn|Components|CharacterMovement")
57 FORCEINLINE
float GetLeanAngle()
const
62 UFUNCTION(BlueprintCallable, Category =
"Pawn|Components|CharacterMovement")
63 FORCEINLINE
void SetLeanAngle(const
float Angle)
68 UFUNCTION(BlueprintPure, Category =
"Pawn|Components|CharacterMovement")
69 FORCEINLINE
float GetLeaningVelocity()
const
71 return LeaningVelocity;
74 UFUNCTION(BlueprintCallable, Category =
"Pawn|Components|CharacterMovement")
75 FORCEINLINE
void SetExtraVelocity(const FVector& NewExtraVelocity)
77 ExtraVelocity = NewExtraVelocity;
81 virtual FRotator ComputeOrientToMovementRotation(
const FRotator& CurrentRotation,
float DeltaTime, FRotator& DeltaRotation)
const override;
82 virtual FVector CalcAnimRootMotionVelocity(
const FVector& RootMotionDeltaMove,
float DeltaSeconds,
const FVector& CurrentVelocity)
const override;
83 virtual void PhysicsRotation(
float DeltaTime)
override;
85 float CalculateTargetLeanAngle(
float DeltaTime,
bool bIsMoved)
const;
86 void UpdateLeaning(
float DeltaTime,
bool bIsMoved);
89 FORCEINLINE
void ResetMovementInputRotation()
91 LastMovementInputYaw = 0.0f;
92 MovementInputYawDelta = 0.0f;
93 CameraFollowYawSpeed = 0.0f;
94 bHasMovementInputRotation =
false;
97 FORCEINLINE
float GetAppliedMovementInputYawDelta()
const
99 return MovementInputYawDelta * FMath::Clamp(CameraRotationFollowRatio, 0.0f, 1.0f);
104 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category =
"Character Movement: Running", meta = (ClampMin =
"0.0", Units =
"cm/s"))
105 float MaxRunSpeed = 800.0f;
111 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement:
Running")
112 FRuntimeFloatCurve MovementSpeedCurve;
115 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Turning", meta = (ClampMin = "0.0", ClampMax = "1.0"))
116 float CameraRotationFollowRatio = 1.0f;
125 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Turning")
126 FRuntimeFloatCurve TurnRateCurve;
134 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning")
135 bool bLeaningEnabled = true;
137 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning")
138 bool bBlockLean = false;
140 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning")
141 bool bShouldResetRotationOnBlock = true;
144 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning", meta = (ClampMin = "0.0", ClampMax = "90.0", Units = "deg"))
145 float TiltStrength = 12.0f;
147 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning", meta = (ClampMin = "0.01", ClampMax = "0.5", Units = "s"))
148 float TiltSmoothTime = 0.17f;
151 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning", meta = (ClampMin = "0.0", Units = "deg/s"))
152 float CameraLeanYawSpeedForMaxAngle = 360.0f;
155 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning", meta = (ClampMin = "0.0", Units = "deg/s"))
156 float MovementLeanYawSpeedForMaxAngle = 70.0f;
159 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning", meta = (ClampMin = "0.0", Units = "cm/s"))
160 float MovementThreshold = 1.0f;
162 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement (General Settings)", meta = (ClampMin = "0.0", Units = "s"))
163 float RootMotionInertiaBlendOutDuration = 0.1f;
166 FVector ExtraVelocity = FVector::ZeroVector;
169 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character Movement (General Settings)", meta = (AllowPrivateAccess = true))
170 float CurrentMovementSpeed = 0.0f;
172 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning", meta = (AllowPrivateAccess = true))
173 float LeanAngle = 0.0f;
176 float AppliedCameraYawDelta = 0.0f;
177 float AppliedMovementYawDelta = 0.0f;
178 float CameraFollowYawSpeed = 0.0f;
179 float MovementInputYawDelta = 0.0f;
180 float LastActorYaw = 0.0f;
181 float LastMovementInputYaw = 0.0f;
182 float LeaningVelocity = 0.0f;
184 bool bHasMovementInputRotation = false;
185 bool bHasLastActorYaw = false;