Payback 0.0.1
CK Graduation Project
로딩중...
검색중...
일치하는것 없음
PlayerMovementComponent.h
이 파일의 문서화 페이지로 가기
1#pragma once
2
3#include "CK_UE.h"
4#include "Curves/CurveFloat.h"
6#include "PlayerMovementComponent.generated.h"
7
8
9UCLASS(ClassGroup = (Movement), meta = (BlueprintSpawnableComponent))
10class CK_UE_API UPlayerMovementComponent : public UCharacterMovementComponentBase
11{
12 GENERATED_BODY()
13
14public:
15 UPlayerMovementComponent();
16
17public:
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;
21
22public:
23 void UpdateMovementInputRotation(const FRotator& MovementInputRotation);
24
25public:
26 UFUNCTION(BlueprintCallable, Category = "Pawn|Components|CharacterMovement")
27 void SetLeaningEnabled(bool bEnabled);
28
29 UFUNCTION(BlueprintPure, Category = "Pawn|Components|CharacterMovement")
30 float GetRunSpeedAlpha() const;
31
32 UFUNCTION(BlueprintPure, Category = "Pawn|Components|CharacterMovement")
33 FORCEINLINE float GetWalkSpeed() const
34 {
35 return MaxWalkSpeed;
36 }
37
38 UFUNCTION(BlueprintPure, Category = "Pawn|Components|CharacterMovement")
39 FORCEINLINE float GetRunSpeed() const
40 {
41 return MaxRunSpeed;
42 }
43
44 UFUNCTION(BlueprintPure, Category = "Pawn|Components|CharacterMovement")
45 FORCEINLINE float GetCurrentMovementSpeed() const
46 {
47 return CurrentMovementSpeed;
48 }
49
50 UFUNCTION(BlueprintPure, Category = "Pawn|Components|CharacterMovement")
51 FORCEINLINE bool IsLeaningEnabled() const
52 {
53 return bLeaningEnabled;
54 }
55
56 UFUNCTION(BlueprintPure, Category = "Pawn|Components|CharacterMovement")
57 FORCEINLINE float GetLeanAngle() const
58 {
59 return LeanAngle;
60 }
61
62 UFUNCTION(BlueprintCallable, Category = "Pawn|Components|CharacterMovement")
63 FORCEINLINE void SetLeanAngle(const float Angle)
64 {
65 LeanAngle = Angle;
66 }
67
68 UFUNCTION(BlueprintPure, Category = "Pawn|Components|CharacterMovement")
69 FORCEINLINE float GetLeaningVelocity() const
70 {
71 return LeaningVelocity;
72 }
73
74 UFUNCTION(BlueprintCallable, Category = "Pawn|Components|CharacterMovement")
75 FORCEINLINE void SetExtraVelocity(const FVector& NewExtraVelocity)
76 {
77 ExtraVelocity = NewExtraVelocity;
78 }
79
80protected:
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;
84
85 float CalculateTargetLeanAngle(float DeltaTime, bool bIsMoved) const;
86 void UpdateLeaning(float DeltaTime, bool bIsMoved);
87
88protected:
89 FORCEINLINE void ResetMovementInputRotation()
90 {
91 LastMovementInputYaw = 0.0f;
92 MovementInputYawDelta = 0.0f;
93 CameraFollowYawSpeed = 0.0f;
94 bHasMovementInputRotation = false;
95 }
96
97 FORCEINLINE float GetAppliedMovementInputYawDelta() const
98 {
99 return MovementInputYawDelta * FMath::Clamp(CameraRotationFollowRatio, 0.0f, 1.0f);
100 }
101
102protected:
104 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Running", meta = (ClampMin = "0.0", Units = "cm/s"))
105 float MaxRunSpeed = 800.0f;
106
111 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Running")
112 FRuntimeFloatCurve MovementSpeedCurve;
113
115 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Turning", meta = (ClampMin = "0.0", ClampMax = "1.0"))
116 float CameraRotationFollowRatio = 1.0f;
117
125 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Turning")
126 FRuntimeFloatCurve TurnRateCurve;
127
128 // /** X축 정규화 이동 속도(0~1, 최대 이동 속도 대비)를 Y축 몸(메시) 회전 각속도(deg/s)로 변환한다.
129 // 매 틱 RotationRate.Yaw에 적용된다.
130 // 이동 경로의 코너(TurningDragCurve)와는 별개로 캐릭터가 바라보는 방향이 도는 빠르기만 결정한다. */
131 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Turning")
132 // FRuntimeFloatCurve BodyRotationSpeedCurve;
133
134 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning")
135 bool bLeaningEnabled = true;
136
137 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning")
138 bool bBlockLean = false;
139
140 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning")
141 bool bShouldResetRotationOnBlock = true;
142
144 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning", meta = (ClampMin = "0.0", ClampMax = "90.0", Units = "deg"))
145 float TiltStrength = 12.0f;
146
147 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning", meta = (ClampMin = "0.01", ClampMax = "0.5", Units = "s"))
148 float TiltSmoothTime = 0.17f;
149
151 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning", meta = (ClampMin = "0.0", Units = "deg/s"))
152 float CameraLeanYawSpeedForMaxAngle = 360.0f;
153
155 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning", meta = (ClampMin = "0.0", Units = "deg/s"))
156 float MovementLeanYawSpeedForMaxAngle = 70.0f;
157
159 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning", meta = (ClampMin = "0.0", Units = "cm/s"))
160 float MovementThreshold = 1.0f;
161
162 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character Movement (General Settings)", meta = (ClampMin = "0.0", Units = "s"))
163 float RootMotionInertiaBlendOutDuration = 0.1f;
164
165 UPROPERTY(Transient)
166 FVector ExtraVelocity = FVector::ZeroVector;
167
168private:
169 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character Movement (General Settings)", meta = (AllowPrivateAccess = true))
170 float CurrentMovementSpeed = 0.0f;
171
172 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character Movement: Leaning", meta = (AllowPrivateAccess = true))
173 float LeanAngle = 0.0f;
174
175private:
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;
183
184 bool bHasMovementInputRotation = false;
185 bool bHasLastActorYaw = false;
186};