17{
19 {
20 return;
21 }
22
25
27 FVector Start = TraceTransform.GetLocation();
28 FVector Forward = TraceTransform.GetRotation().GetForwardVector();
29
30 FVector Center = Start + (Forward * CurrentForwardDistance * 0.5f);
31
32 float CapsuleHalfHeight = (CurrentForwardDistance * 0.5f) + CurrentRadius;
33
34 FQuat CapsuleRot = FRotationMatrix::MakeFromZ(Forward).ToQuat();
35
37 TArray<FOverlapResult> Overlaps;
38
39 GetWorld()->OverlapMultiByChannel(
40 Overlaps,
41 Center,
42 CapsuleRot,
44 FCollisionShape::MakeCapsule(CurrentRadius, CapsuleHalfHeight),
45 Params
46 );
47
48 for (const FOverlapResult& Overlap : Overlaps)
49 {
50
51 AActor* OverlapActor = Overlap.GetActor();
52 if (!IsValid(OverlapActor))
53 {
54 continue;
55 }
56
57 FVector EnemyLocation = Overlap.GetActor()->GetActorLocation();
58 FVector DirToPlayer = (Start - EnemyLocation).GetSafeNormal();
59
60 FHitResult FakeHit(Overlap.GetActor(), Overlap.Component.Get(), EnemyLocation, DirToPlayer);
61 FakeHit.ImpactPoint = EnemyLocation;
62
63 OutHits.Add(FakeHit);
64 }
65
66#if ENABLE_DRAW_DEBUG
68 {
69 FColor DrawColor = OutHits.Num() > 0 ? FColor::Green : FColor::Red;
70 DrawDebugCapsule(GetWorld(), Center, CapsuleHalfHeight, CurrentRadius, CapsuleRot, DrawColor, false, 1.0f);
71 }
72#endif
73
74}
Definition TA_CapsuleOverlap.h:12
float CombatDataLevel
Definition TA_Trace.h:85
ECollisionChannel TraceChannel
Definition TA_Trace.h:86
bool IsDebugEnabled() const
Definition TA_Trace.cpp:166
TObjectPtr< ACharacter > Character
Definition TA_Trace.h:100
FTransform ResolveTraceTransform() const
Definition TA_Trace.cpp:145