62 const float Radius = CapsuleComp->GetScaledCapsuleRadius();
63 FVector
const CollisionSlice(Radius, Radius, 1.f);
66 float ScaledHalfHeight = CapsuleComp->GetScaledCapsuleHalfHeight();
67 const FVector TraceStart = GetActorLocation() + FVector(0.f, 0.f, ScaledHalfHeight);
68 const FVector TraceEnd = GetActorLocation() - FVector(0.f, 0.f, 2.f * ScaledHalfHeight);
70 GetWorld()->SweepSingleByObjectType(Hit, TraceStart, TraceEnd, FQuat::Identity, FCollisionObjectQueryParams(ECC_WorldStatic), FCollisionShape::MakeBox(CollisionSlice), FCollisionQueryParams(SCENE_QUERY_STAT(NavFindBase),
false));
88 GetGoodSprite()->SetVisibility(
true);
92 GetBadSprite()->SetVisibility(
false);
98 void Validate()
override
100 if (ShouldBeBased() && (GetGoodSprite() || GetBadSprite()))
106 FVector OrigLocation = GetActorLocation();
107 const float Radius = CapsuleComp->GetScaledCapsuleRadius();
108 FVector
const Slice(Radius, Radius, 1.f);
113 FHitResult Hit(ForceInit);
114 float ScaledHalfHeight = CapsuleComp->GetScaledCapsuleHalfHeight();
115 const FVector TraceStart = GetActorLocation() + FVector(0.f, 0.f, ScaledHalfHeight);
116 const FVector TraceEnd = GetActorLocation() - FVector(0.f, 0.f, 4.f * ScaledHalfHeight);
117 GetWorld()->SweepSingleByChannel(Hit, TraceStart, TraceEnd, FQuat::Identity, ECC_Pawn, FCollisionShape::MakeBox(Slice), FCollisionQueryParams(SCENE_QUERY_STAT(NavObjectBase_Validate),
false,
this));
118 if (Hit.bBlockingHit)
120 const FVector HitLocation = TraceStart + (TraceEnd - TraceStart) * Hit.Time;
121 FVector Dest = HitLocation - FVector(0.f, 0.f, 2.f);
124 TeleportTo(Dest, GetActorRotation(),
false,
true);
127 FVector NewLocation = GetActorLocation();
128 bResult = (NewLocation.X == OrigLocation.X &&
129 NewLocation.Y == OrigLocation.Y &&
130 NewLocation.Z <= OrigLocation.Z);
133 TeleportTo(OrigLocation, GetActorRotation(),
false,
true);
139 GetGoodSprite()->SetVisibility(bResult);
143 GetBadSprite()->SetVisibility(!bResult);
148 MarkComponentsRenderStateDirty();