Space Plunder
Loading...
Searching...
No Matches
UALSMantleComponent Class Reference

#include <ALSMantleComponent.h>

Inheritance diagram for UALSMantleComponent:

Public Member Functions

 UALSMantleComponent ()
 
bool MantleCheck (const FALSMantleTraceSettings &TraceSettings, EDrawDebugTrace::Type DebugType)
 
void MantleStart (float MantleHeight, const FALSComponentAndTransform &MantleLedgeWS, EALSMantleType MantleType)
 
void MantleUpdate (float BlendIn)
 
void MantleEnd ()
 
void OnOwnerJumpInput ()
 
void OnOwnerRagdollStateChanged (bool bRagdollState)
 
FALSMantleAsset GetMantleAsset (EALSMantleType MantleType, EALSOverlayState CurrentOverlayState)
 
bool IsMantlePlaying ()
 

Protected Member Functions

virtual void TickComponent (float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override
 
virtual void BeginPlay () override
 
void Server_MantleStart (float MantleHeight, const FALSComponentAndTransform &MantleLedgeWS, EALSMantleType MantleType)
 
void Multicast_MantleStart (float MantleHeight, const FALSComponentAndTransform &MantleLedgeWS, EALSMantleType MantleType)
 

Protected Attributes

TObjectPtr< UTimelineComponent > MantleTimeline = nullptr
 
FALSMantleTraceSettings GroundedTraceSettings
 
FALSMantleTraceSettings AutomaticTraceSettings
 
FALSMantleTraceSettings FallingTraceSettings
 
TObjectPtr< UCurveFloat > MantleTimelineCurve
 
FName MantleObjectDetectionProfile = NAME_IgnoreOnlyPawn
 
TEnumAsByte< ECollisionChannel > WalkableSurfaceDetectionChannel = ECC_Visibility
 
FALSMantleParams MantleParams
 
FALSComponentAndTransform MantleLedgeLS
 
FTransform MantleTarget = FTransform::Identity
 
FTransform MantleActualStartOffset = FTransform::Identity
 
FTransform MantleAnimatedStartOffset = FTransform::Identity
 
float AcceptableVelocityWhileMantling = 10.0f
 

Static Protected Attributes

static FName NAME_IgnoreOnlyPawn
 

Private Attributes

TObjectPtr< AALSBaseCharacterOwnerCharacter
 
TObjectPtr< UALSDebugComponentALSDebugComponent = nullptr
 
bool bPhysicActor = false
 

Constructor & Destructor Documentation

◆ UALSMantleComponent()

UALSMantleComponent::UALSMantleComponent ( )
29{
30 PrimaryComponentTick.bCanEverTick = true;
31 PrimaryComponentTick.bStartWithTickEnabled = true;
32
33 MantleTimeline = CreateDefaultSubobject<UTimelineComponent>(NAME_MantleTimeline);
34}
const FName NAME_MantleTimeline(TEXT("MantleTimeline"))
TObjectPtr< UTimelineComponent > MantleTimeline
Definition ALSMantleComponent.h:73

Member Function Documentation

◆ BeginPlay()

void UALSMantleComponent::BeginPlay ( )
overrideprotectedvirtual
37{
38 TRACE_CPUPROFILER_EVENT_SCOPE(UALSMantleComponent::BeginPlay);
39 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Mantle_Component);
40
41 Super::BeginPlay();
42
43 if (GetOwner())
44 {
45 OwnerCharacter = Cast<AALSBaseCharacter>(GetOwner());
47 {
48 ALSDebugComponent = OwnerCharacter->FindComponentByClass<UALSDebugComponent>();
49
50 AddTickPrerequisiteActor(OwnerCharacter); // Always tick after owner, so we'll use updated values
51
52 // Bindings
53 FOnTimelineFloat TimelineUpdated;
54 FOnTimelineEvent TimelineFinished;
55 TimelineUpdated.BindUFunction(this, NAME_MantleUpdate);
56 TimelineFinished.BindUFunction(this, NAME_MantleEnd);
57 MantleTimeline->SetTimelineFinishedFunc(TimelineFinished);
58 MantleTimeline->SetLooping(false);
59 MantleTimeline->SetTimelineLengthMode(TL_TimelineLength);
60 MantleTimeline->AddInterpFloat(MantleTimelineCurve, TimelineUpdated);
61
62 OwnerCharacter->JumpPressedDelegate.AddUniqueDynamic(this, &UALSMantleComponent::OnOwnerJumpInput);
63 OwnerCharacter->RagdollStateChangedDelegate.AddUniqueDynamic(
65 }
66 }
67}
const FName NAME_MantleUpdate(TEXT("MantleUpdate"))
const FName NAME_MantleEnd(TEXT("MantleEnd"))
Definition ALSDebugComponent.h:17
TObjectPtr< AALSBaseCharacter > OwnerCharacter
Definition ALSMantleComponent.h:116
TObjectPtr< UALSDebugComponent > ALSDebugComponent
Definition ALSMantleComponent.h:119
virtual void BeginPlay() override
Definition ALSMantleComponent.cpp:36
void OnOwnerRagdollStateChanged(bool bRagdollState)
Definition ALSMantleComponent.cpp:473
TObjectPtr< UCurveFloat > MantleTimelineCurve
Definition ALSMantleComponent.h:85
void OnOwnerJumpInput()
Definition ALSMantleComponent.cpp:450

◆ GetMantleAsset()

FALSMantleAsset UALSMantleComponent::GetMantleAsset ( EALSMantleType MantleType,
EALSOverlayState CurrentOverlayState )

Implement on BP to get correct mantle parameter set according to character state

◆ IsMantlePlaying()

bool UALSMantleComponent::IsMantlePlaying ( )
inline
53{if(MantleTimeline == nullptr){return false;}return MantleTimeline->IsPlaying();};

◆ MantleCheck()

bool UALSMantleComponent::MantleCheck ( const FALSMantleTraceSettings & TraceSettings,
EDrawDebugTrace::Type DebugType )
177{
178 TRACE_CPUPROFILER_EVENT_SCOPE(UALSMantleComponent::MantleCheck);
179 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Mantle_Component);
180
181 if (!OwnerCharacter)
182 {
183 return false;
184 }
185
186 // Step 1: Trace forward to find a wall / object the character cannot walk on.
187 const FVector& TraceDirection = OwnerCharacter->GetActorForwardVector();
188 const FVector& CapsuleBaseLocation = UALSMathLibrary::GetCapsuleBaseLocation(
189 2.0f, OwnerCharacter->GetCapsuleComponent());
190 FVector TraceStart = CapsuleBaseLocation + TraceDirection * -30.0f;
191 TraceStart.Z += (TraceSettings.MaxLedgeHeight + TraceSettings.MinLedgeHeight) / 2.0f;
192 const FVector TraceEnd = TraceStart + TraceDirection * TraceSettings.ReachDistance;
193 const float HalfHeight = 1.0f + (TraceSettings.MaxLedgeHeight - TraceSettings.MinLedgeHeight) / 2.0f;
194
195 UWorld* World = GetWorld();
196 check(World);
197
198 FCollisionQueryParams Params;
199 Params.AddIgnoredActor(OwnerCharacter);
200
201 FHitResult HitResult;
202 {
203 const FCollisionShape CapsuleCollisionShape = FCollisionShape::MakeCapsule(TraceSettings.ForwardTraceRadius, HalfHeight);
204 const bool bHit = World->SweepSingleByProfile(HitResult, TraceStart, TraceEnd, FQuat::Identity, MantleObjectDetectionProfile,
205 CapsuleCollisionShape, Params);
206
207 if (ALSDebugComponent && ALSDebugComponent->GetShowTraces())
208 {
210 TraceStart,
211 TraceEnd,
212 CapsuleCollisionShape,
213 DebugType,
214 bHit,
215 HitResult,
216 FLinearColor::Black,
217 FLinearColor::Black,
218 1.0f);
219 }
220 }
221
222 if (!HitResult.IsValidBlockingHit() || OwnerCharacter->GetCharacterMovement()->IsWalkable(HitResult))
223 {
224 // Not a valid surface to mantle
225 return false;
226 }
227
228 if (HitResult.GetComponent() != nullptr)
229 {
230 UPrimitiveComponent* PrimitiveComponent = HitResult.GetComponent();
231 if (PrimitiveComponent && PrimitiveComponent->GetComponentVelocity().Size() > AcceptableVelocityWhileMantling)
232 {
233 // The surface to mantle moves too fast
234 return false;
235 }
236 }
237
238 const FVector InitialTraceImpactPoint = HitResult.ImpactPoint;
239 const FVector InitialTraceNormal = HitResult.ImpactNormal;
240
241 // Step 2: Trace downward from the first trace's Impact Point and determine if the hit location is walkable.
242 FVector DownwardTraceEnd = InitialTraceImpactPoint;
243 DownwardTraceEnd.Z = CapsuleBaseLocation.Z;
244 DownwardTraceEnd += InitialTraceNormal * -15.0f;
245 FVector DownwardTraceStart = DownwardTraceEnd;
246 DownwardTraceStart.Z += TraceSettings.MaxLedgeHeight + TraceSettings.DownwardTraceRadius + 1.0f;
247
248 {
249 const FCollisionShape SphereCollisionShape = FCollisionShape::MakeSphere(TraceSettings.DownwardTraceRadius);
250 const bool bHit = World->SweepSingleByChannel(HitResult, DownwardTraceStart, DownwardTraceEnd, FQuat::Identity,
251 WalkableSurfaceDetectionChannel, SphereCollisionShape,
252 Params);
253
254 if (ALSDebugComponent && ALSDebugComponent->GetShowTraces())
255 {
257 TraceStart,
258 TraceEnd,
259 SphereCollisionShape,
260 DebugType,
261 bHit,
262 HitResult,
263 FLinearColor::Black,
264 FLinearColor::Black,
265 1.0f);
266 }
267 }
268
269
270 if (!OwnerCharacter->GetCharacterMovement()->IsWalkable(HitResult))
271 {
272 // Not a valid surface to mantle
273 return false;
274 }
275
276 const FVector DownTraceLocation(HitResult.Location.X, HitResult.Location.Y, HitResult.ImpactPoint.Z);
277 UPrimitiveComponent* HitComponent = HitResult.GetComponent();
278
279 // Step 3: Check if the capsule has room to stand at the downward trace's location.
280 // If so, set that location as the Target Transform and calculate the mantle height.
281 const FVector& CapsuleLocationFBase = UALSMathLibrary::GetCapsuleLocationFromBase(
282 DownTraceLocation, 2.0f, OwnerCharacter->GetCapsuleComponent());
283 const bool bCapsuleHasRoom = UALSMathLibrary::CapsuleHasRoomCheck(OwnerCharacter->GetCapsuleComponent(),
284 CapsuleLocationFBase, 0.0f,
285 0.0f, DebugType, ALSDebugComponent && ALSDebugComponent->GetShowTraces());
286
287 if (!bCapsuleHasRoom)
288 {
289 // Capsule doesn't have enough room to mantle
290 return false;
291 }
292
293 const FTransform TargetTransform(
294 (InitialTraceNormal * FVector(-1.0f, -1.0f, 0.0f)).ToOrientationRotator(),
295 CapsuleLocationFBase,
296 FVector::OneVector);
297
298 const float MantleHeight = (CapsuleLocationFBase - OwnerCharacter->GetActorLocation()).Z;
299
300 // Step 4: Determine the Mantle Type by checking the movement mode and Mantle Height.
301 EALSMantleType MantleType;
302 if (OwnerCharacter->GetMovementState() == EALSMovementState::InAir)
303 {
304 MantleType = EALSMantleType::FallingCatch;
305 }
306 else
307 {
308 MantleType = MantleHeight > 125.0f ? EALSMantleType::HighMantle : EALSMantleType::LowMantle;
309 }
310
311 // Step 4.1: Fix FallingCatch Mantle on low walls or objects
312 if (MantleType == EALSMantleType::FallingCatch)
313 {
314 FVector GroundTraceStart = CapsuleBaseLocation;
315 GroundTraceStart.Z = DownTraceLocation.Z;
316 FVector GroundTraceEnd = GroundTraceStart;
317 GroundTraceEnd.Z -= 70.0f;
318
319 const float CapsuleRadius = OwnerCharacter->GetCapsuleComponent()->GetScaledCapsuleRadius();
320 const FCollisionShape CapsuleCollisionShape = FCollisionShape::MakeCapsule(CapsuleRadius, CapsuleRadius);
321 const bool bHitGround = World->SweepSingleByProfile(HitResult, GroundTraceStart, GroundTraceEnd, FQuat::Identity, MantleObjectDetectionProfile, CapsuleCollisionShape, Params);
322
323 if (bHitGround)
324 {
325 return false;
326 }
327 }
328 // Step 5: If everything checks out, start the Mantle
330 MantleWS.Component = HitComponent;
331 MantleWS.Transform = TargetTransform;
332 MantleStart(MantleHeight, MantleWS, MantleType);
333 Server_MantleStart(MantleHeight, MantleWS, MantleType);
334
335 return true;
336}
EALSMantleType
Definition ALSCharacterEnumLibrary.h:161
static void DrawDebugSphereTraceSingle(const UWorld *World, const FVector &Start, const FVector &End, const FCollisionShape &CollisionShape, EDrawDebugTrace::Type DrawDebugType, bool bHit, const FHitResult &OutHit, FLinearColor TraceColor, FLinearColor TraceHitColor, float DrawTime)
Definition ALSDebugComponent.cpp:337
static void DrawDebugCapsuleTraceSingle(const UWorld *World, const FVector &Start, const FVector &End, const FCollisionShape &CollisionShape, EDrawDebugTrace::Type DrawDebugType, bool bHit, const FHitResult &OutHit, FLinearColor TraceColor, FLinearColor TraceHitColor, float DrawTime)
Definition ALSDebugComponent.cpp:275
bool MantleCheck(const FALSMantleTraceSettings &TraceSettings, EDrawDebugTrace::Type DebugType)
Definition ALSMantleComponent.cpp:176
FName MantleObjectDetectionProfile
Definition ALSMantleComponent.h:90
TEnumAsByte< ECollisionChannel > WalkableSurfaceDetectionChannel
Definition ALSMantleComponent.h:93
void Server_MantleStart(float MantleHeight, const FALSComponentAndTransform &MantleLedgeWS, EALSMantleType MantleType)
void MantleStart(float MantleHeight, const FALSComponentAndTransform &MantleLedgeWS, EALSMantleType MantleType)
Definition ALSMantleComponent.cpp:89
float AcceptableVelocityWhileMantling
Definition ALSMantleComponent.h:112
static FVector GetCapsuleBaseLocation(float ZOffset, UCapsuleComponent *Capsule)
Definition ALSMathLibrary.cpp:22
static FVector GetCapsuleLocationFromBase(FVector BaseLocation, float ZOffset, UCapsuleComponent *Capsule)
Definition ALSMathLibrary.cpp:28
static bool CapsuleHasRoomCheck(UCapsuleComponent *Capsule, FVector TargetLocation, float HeightOffset, float RadiusOffset, EDrawDebugTrace::Type DebugType=EDrawDebugTrace::Type::None, bool DrawDebugTrace=false)
Definition ALSMathLibrary.cpp:35
Definition ALSCharacterStructLibrary.h:31
TObjectPtr< UPrimitiveComponent > Component
Definition ALSCharacterStructLibrary.h:38
FTransform Transform
Definition ALSCharacterStructLibrary.h:35
float MinLedgeHeight
Definition ALSCharacterStructLibrary.h:162
float ReachDistance
Definition ALSCharacterStructLibrary.h:165
float DownwardTraceRadius
Definition ALSCharacterStructLibrary.h:171
float ForwardTraceRadius
Definition ALSCharacterStructLibrary.h:168
float MaxLedgeHeight
Definition ALSCharacterStructLibrary.h:159

◆ MantleEnd()

void UALSMantleComponent::MantleEnd ( )
426{
427 TRACE_CPUPROFILER_EVENT_SCOPE(UALSMantleComponent::MantleEnd);
428 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Mantle_Component);
429
430 // Set the Character Movement Mode to Walking
431 if (OwnerCharacter)
432 {
433 OwnerCharacter->GetCharacterMovement()->SetMovementMode(MOVE_Walking);
434
435 if (OwnerCharacter->IsA(AALSCharacter::StaticClass()))
436 {
437 Cast<AALSCharacter>(OwnerCharacter)->UpdateHeldObject();
438 }
439
440 if (bPhysicActor)
441 {
442 MantleLedgeLS.Component.Get()->SetSimulatePhysics(true);
443 }
444 }
445
446 // Enable ticking back after mantle ends
447 SetComponentTickEnabledAsync(true);
448}
void MantleEnd()
Definition ALSMantleComponent.cpp:425
bool bPhysicActor
Definition ALSMantleComponent.h:122
FALSComponentAndTransform MantleLedgeLS
Definition ALSMantleComponent.h:99

◆ MantleStart()

void UALSMantleComponent::MantleStart ( float MantleHeight,
const FALSComponentAndTransform & MantleLedgeWS,
EALSMantleType MantleType )
91{
92 TRACE_CPUPROFILER_EVENT_SCOPE(UALSMantleComponent::MantleStart);
93 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Mantle_Component);
94
95 if (OwnerCharacter == nullptr || !IsValid(MantleLedgeWS.Component) || !IsValid(MantleTimeline))
96 {
97 return;
98 }
99
100 if (MantleType != EALSMantleType::LowMantle && OwnerCharacter->IsA(AALSCharacter::StaticClass()))
101 {
102 Cast<AALSCharacter>(OwnerCharacter)->ClearHeldObject();
103 }
104
105 // Disable ticking during mantle
106 SetComponentTickEnabledAsync(false);
107
108 // Step 1: Get the Mantle Asset and use it to set the new Mantle Params.
109 const FALSMantleAsset MantleAsset = GetMantleAsset(MantleType, OwnerCharacter->GetOverlayState());
110 check(MantleAsset.PositionCorrectionCurve)
111
112 MantleParams.AnimMontage = MantleAsset.AnimMontage;
113 MantleParams.PositionCorrectionCurve = MantleAsset.PositionCorrectionCurve;
114 MantleParams.StartingOffset = MantleAsset.StartingOffset;
115 MantleParams.StartingPosition = FMath::GetMappedRangeValueClamped<float, float>({MantleAsset.LowHeight, MantleAsset.HighHeight},
116 {
117 MantleAsset.LowStartPosition,
118 MantleAsset.HighStartPosition
119 },
120 MantleHeight);
121 MantleParams.PlayRate = FMath::GetMappedRangeValueClamped<float, float>({MantleAsset.LowHeight, MantleAsset.HighHeight},
122 {MantleAsset.LowPlayRate, MantleAsset.HighPlayRate},
123 MantleHeight);
124
125 // Step 2: Convert the world space target to the mantle component's local space for use in moving objects.
126 MantleLedgeLS.Component = MantleLedgeWS.Component;
127 MantleLedgeLS.Transform = MantleLedgeWS.Transform * MantleLedgeWS.Component->GetComponentToWorld().Inverse();
128
129 // Step 3: Set the Mantle Target and calculate the Starting Offset
130 // (offset amount between the actor and target transform).
131 MantleTarget = MantleLedgeWS.Transform;
133
134 // Step 4: Calculate the Animated Start Offset from the Target Location.
135 // This would be the location the actual animation starts at relative to the Target Transform.
136 FVector RotatedVector = MantleTarget.GetRotation().Vector() * MantleParams.StartingOffset.Y;
137 RotatedVector.Z = MantleParams.StartingOffset.Z;
138 const FTransform StartOffset(MantleTarget.Rotator(), MantleTarget.GetLocation() - RotatedVector,
139 FVector::OneVector);
141
142 // Step 5: Clear the Character Movement Mode and set the Movement State to Mantling
143 OwnerCharacter->GetCharacterMovement()->SetMovementMode(MOVE_None);
145
146 //- Check Physics for security -//
147 if(MantleLedgeLS.Component.Get()->IsSimulatingPhysics())
148 {
149 bPhysicActor = true;
150 MantleLedgeLS.Component.Get()->SetSimulatePhysics(false);
151 }
152 else
153 {
154 bPhysicActor = false;
155 }
156
157 // Step 6: Configure the Mantle Timeline so that it is the same length as the
158 // Lerp/Correction curve minus the starting position, and plays at the same speed as the animation.
159 // Then start the timeline.
160 float MinTime = 0.0f;
161 float MaxTime = 0.0f;
162 MantleParams.PositionCorrectionCurve->GetTimeRange(MinTime, MaxTime);
163 MantleTimeline->SetTimelineLength(MaxTime - MantleParams.StartingPosition);
165 MantleTimeline->PlayFromStart();
166
167 // Step 7: Play the Anim Montage if valid.
168 if (MantleParams.AnimMontage && OwnerCharacter->GetMesh()->GetAnimInstance())
169 {
170 OwnerCharacter->GetMesh()->GetAnimInstance()->Montage_Play(MantleParams.AnimMontage, MantleParams.PlayRate,
171 EMontagePlayReturnType::MontageLength,
173 }
174}
FTransform MantleAnimatedStartOffset
Definition ALSMantleComponent.h:108
FALSMantleAsset GetMantleAsset(EALSMantleType MantleType, EALSOverlayState CurrentOverlayState)
FTransform MantleTarget
Definition ALSMantleComponent.h:102
FALSMantleParams MantleParams
Definition ALSMantleComponent.h:96
FTransform MantleActualStartOffset
Definition ALSMantleComponent.h:105
static FTransform TransformSub(const FTransform &T1, const FTransform &T2)
Definition ALSMathLibrary.h:28
Definition ALSCharacterStructLibrary.h:101
float HighHeight
Definition ALSCharacterStructLibrary.h:123
float LowStartPosition
Definition ALSCharacterStructLibrary.h:120
float LowHeight
Definition ALSCharacterStructLibrary.h:114
float HighStartPosition
Definition ALSCharacterStructLibrary.h:129
float LowPlayRate
Definition ALSCharacterStructLibrary.h:117
float HighPlayRate
Definition ALSCharacterStructLibrary.h:126
TObjectPtr< UCurveVector > PositionCorrectionCurve
Definition ALSCharacterStructLibrary.h:108
float PlayRate
Definition ALSCharacterStructLibrary.h:147
TObjectPtr< UCurveVector > PositionCorrectionCurve
Definition ALSCharacterStructLibrary.h:141
float StartingPosition
Definition ALSCharacterStructLibrary.h:144
TObjectPtr< UAnimMontage > AnimMontage
Definition ALSCharacterStructLibrary.h:138
FVector StartingOffset
Definition ALSCharacterStructLibrary.h:150

◆ MantleUpdate()

void UALSMantleComponent::MantleUpdate ( float BlendIn)
357{
358 TRACE_CPUPROFILER_EVENT_SCOPE(UALSMantleComponent::MantleUpdate);
359 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Mantle_Component);
360
361 if (!OwnerCharacter)
362 {
363 return;
364 }
365
366 // Step 1: Continually update the mantle target from the stored local transform to follow along with moving objects
368
369 // Step 2: Update the Position and Correction Alphas using the Position/Correction curve set for each Mantle.
370 const FVector CurveVec = MantleParams.PositionCorrectionCurve
371 ->GetVectorValue(
372 MantleParams.StartingPosition + MantleTimeline->GetPlaybackPosition());
373 const float PositionAlpha = CurveVec.X;
374 const float XYCorrectionAlpha = CurveVec.Y;
375 const float ZCorrectionAlpha = CurveVec.Z;
376
377 // Step 3: Lerp multiple transforms together for independent control over the horizontal
378 // and vertical blend to the animated start position, as well as the target position.
379
380 // Blend into the animated horizontal and rotation offset using the Y value of the Position/Correction Curve.
381 const FTransform TargetHzTransform(MantleAnimatedStartOffset.GetRotation(),
382 {
383 MantleAnimatedStartOffset.GetLocation().X,
384 MantleAnimatedStartOffset.GetLocation().Y,
385 MantleActualStartOffset.GetLocation().Z
386 },
387 FVector::OneVector);
388 const FTransform& HzLerpResult =
389 UKismetMathLibrary::TLerp(MantleActualStartOffset, TargetHzTransform, XYCorrectionAlpha);
390
391 // Blend into the animated vertical offset using the Z value of the Position/Correction Curve.
392 const FTransform TargetVtTransform(MantleActualStartOffset.GetRotation(),
393 {
394 MantleActualStartOffset.GetLocation().X,
395 MantleActualStartOffset.GetLocation().Y,
396 MantleAnimatedStartOffset.GetLocation().Z
397 },
398 FVector::OneVector);
399 const FTransform& VtLerpResult =
400 UKismetMathLibrary::TLerp(MantleActualStartOffset, TargetVtTransform, ZCorrectionAlpha);
401
402 const FTransform ResultTransform(HzLerpResult.GetRotation(),
403 {
404 HzLerpResult.GetLocation().X, HzLerpResult.GetLocation().Y,
405 VtLerpResult.GetLocation().Z
406 },
407 FVector::OneVector);
408
409 // Blend from the currently blending transforms into the final mantle target using the X
410 // value of the Position/Correction Curve.
411 const FTransform& ResultLerp = UKismetMathLibrary::TLerp(
413 PositionAlpha);
414
415 // Initial Blend In (controlled in the timeline curve) to allow the actor to blend into the Position/Correction
416 // curve at the midpoint. This prevents pops when mantling an object lower than the animated mantle.
417 const FTransform& LerpedTarget =
418 UKismetMathLibrary::TLerp(UALSMathLibrary::TransformAdd(MantleTarget, MantleActualStartOffset), ResultLerp,
419 BlendIn);
420
421 // Step 4: Set the actors location and rotation to the Lerped Target.
422 OwnerCharacter->SetActorLocationAndTargetRotation(LerpedTarget.GetLocation(), LerpedTarget.GetRotation().Rotator());
423}
void MantleUpdate(float BlendIn)
Definition ALSMantleComponent.cpp:356
static FTransform MantleComponentLocalToWorld(const FALSComponentAndTransform &CompAndTransform)
Definition ALSMathLibrary.cpp:13
static FTransform TransformAdd(const FTransform &T1, const FTransform &T2)
Definition ALSMathLibrary.h:35

◆ Multicast_MantleStart()

void UALSMantleComponent::Multicast_MantleStart ( float MantleHeight,
const FALSComponentAndTransform & MantleLedgeWS,
EALSMantleType MantleType )
protected

◆ OnOwnerJumpInput()

void UALSMantleComponent::OnOwnerJumpInput ( )
451{
452 TRACE_CPUPROFILER_EVENT_SCOPE(UALSMantleComponent::OnOwnerJumpInput);
453 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Mantle_Component);
454
455 // Check if character is able to do one of the special mantling
456
457 if (OwnerCharacter && OwnerCharacter->GetMovementAction() == EALSMovementAction::None)
458 {
459 if (OwnerCharacter->GetMovementState() == EALSMovementState::Grounded)
460 {
461 if (OwnerCharacter->HasMovementInput())
462 {
463 MantleCheck(GroundedTraceSettings, EDrawDebugTrace::Type::ForDuration);
464 }
465 }
466 else if (OwnerCharacter->GetMovementState() == EALSMovementState::InAir)
467 {
468 MantleCheck(FallingTraceSettings, EDrawDebugTrace::Type::ForDuration);
469 }
470 }
471}
FALSMantleTraceSettings GroundedTraceSettings
Definition ALSMantleComponent.h:76
FALSMantleTraceSettings FallingTraceSettings
Definition ALSMantleComponent.h:82

◆ OnOwnerRagdollStateChanged()

void UALSMantleComponent::OnOwnerRagdollStateChanged ( bool bRagdollState)
474{
475 TRACE_CPUPROFILER_EVENT_SCOPE(UALSMantleComponent::OnOwnerRagdollStateChanged);
476 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Mantle_Component);
477
478 // If owner is going into ragdoll state, stop mantling immediately
479 if (bRagdollState)
480 {
481 MantleTimeline->Stop();
482 }
483}

◆ Server_MantleStart()

void UALSMantleComponent::Server_MantleStart ( float MantleHeight,
const FALSComponentAndTransform & MantleLedgeWS,
EALSMantleType MantleType )
protected

Mantling

◆ TickComponent()

void UALSMantleComponent::TickComponent ( float DeltaTime,
ELevelTick TickType,
FActorComponentTickFunction * ThisTickFunction )
overrideprotectedvirtual
72{
73 TRACE_CPUPROFILER_EVENT_SCOPE(UALSMantleComponent::TickComponent);
74 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Mantle_Component);
75 SCOPE_CYCLE_COUNTER(STATGROUP_ALS_Mantle_Component_Tick);
76
77 Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
78
79 if (OwnerCharacter && OwnerCharacter->GetMovementState() == EALSMovementState::InAir)
80 {
81 // Perform a mantle check if falling while movement input is pressed.
82 if (OwnerCharacter->HasMovementInput())
83 {
84 MantleCheck(FallingTraceSettings, EDrawDebugTrace::Type::ForOneFrame);
85 }
86 }
87}
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override
Definition ALSMantleComponent.cpp:70

Member Data Documentation

◆ AcceptableVelocityWhileMantling

float UALSMantleComponent::AcceptableVelocityWhileMantling = 10.0f
protected

If a dynamic object has a velocity bigger than this value, do not start mantle

◆ ALSDebugComponent

TObjectPtr<UALSDebugComponent> UALSMantleComponent::ALSDebugComponent = nullptr
private

◆ AutomaticTraceSettings

FALSMantleTraceSettings UALSMantleComponent::AutomaticTraceSettings
protected

◆ bPhysicActor

bool UALSMantleComponent::bPhysicActor = false
private

◆ FallingTraceSettings

FALSMantleTraceSettings UALSMantleComponent::FallingTraceSettings
protected

◆ GroundedTraceSettings

FALSMantleTraceSettings UALSMantleComponent::GroundedTraceSettings
protected

◆ MantleActualStartOffset

FTransform UALSMantleComponent::MantleActualStartOffset = FTransform::Identity
protected

◆ MantleAnimatedStartOffset

FTransform UALSMantleComponent::MantleAnimatedStartOffset = FTransform::Identity
protected

◆ MantleLedgeLS

FALSComponentAndTransform UALSMantleComponent::MantleLedgeLS
protected

◆ MantleObjectDetectionProfile

FName UALSMantleComponent::MantleObjectDetectionProfile = NAME_IgnoreOnlyPawn
protected

Profile to use to detect objects we allow mantling

◆ MantleParams

FALSMantleParams UALSMantleComponent::MantleParams
protected

◆ MantleTarget

FTransform UALSMantleComponent::MantleTarget = FTransform::Identity
protected

◆ MantleTimeline

TObjectPtr<UTimelineComponent> UALSMantleComponent::MantleTimeline = nullptr
protected

◆ MantleTimelineCurve

TObjectPtr<UCurveFloat> UALSMantleComponent::MantleTimelineCurve
protected

◆ NAME_IgnoreOnlyPawn

FName UALSMantleComponent::NAME_IgnoreOnlyPawn
staticprotected

◆ OwnerCharacter

TObjectPtr<AALSBaseCharacter> UALSMantleComponent::OwnerCharacter
private

◆ WalkableSurfaceDetectionChannel

TEnumAsByte<ECollisionChannel> UALSMantleComponent::WalkableSurfaceDetectionChannel = ECC_Visibility
protected

The documentation for this class was generated from the following files: