Sphere Trace at same location as Hit Event location not returning anything

I have a game with high velocities and physics based movement, vehicles travelling 300-800 m/s. When these vehicles collide with the terrain, I have a custom event set up to trigger. I take the Hit.Location passed into this event and then do a sphere trace with radius of at least 50 unreal units. However, sometimes this sphere trace returns nothing.

How can this be? If the game is telling me something impacted at Hit.Location, then I check that location, how can it not be there? Is the event being triggered after the physics engine moves the pawn, therefore sending a HitResult with false location because the pawn has now moved elsewhere? Does anyone know when during the physics cycle the event is actually triggered?

Appreciate any help or ideas. Here is the relavent code:

void ADrifter::OnRaceHit(UPrimitiveComponent* Comp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{

	float VelocityInHitDirection = FMath::Abs(FVector::DotProduct(Velocity, Hit.Normal));

// DamageMinVelocity = 50.f, ignore low velocity collisions
	if (VelocityInHitDirection < DamageMinVelocity)
		return;

	TArray<FHitResult> HitResultsSphereTrace;
	FCollisionQueryParams CollisionQueryParams;
	CollisionQueryParams.AddIgnoredComponent(Comp);
	CollisionQueryParams.bTraceComplex = true;
	CollisionQueryParams.bDebugQuery = true;
	FCollisionResponseParams CollisionResponseParams;
	FVector Start = Hit.Location;
	TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes;
	TArray<AActor*> IgnoredActors;
	TArray<UPrimitiveComponent*> Overlaps;
	ObjectTypes.Add(UEngineTypes::ConvertToObjectType(DrifterRoot->GetCollisionObjectType()));

	UKismetSystemLibrary::SphereOverlapComponents(GetWorld(), Start, VelocityInHitDirection, ObjectTypes, UPart::StaticClass(), IgnoredActors, Overlaps);

// Returning empty sometimes
	if (Overlaps.IsEmpty())
	{
		DrawDebugSphere(GetWorld(), Start, VelocityInHitDirection, 5, FColor::Red, false, 10.f);
		DrawDebugPoint(GetWorld(), Start, 10.f, FColor::Blue, false, 10.f);
		Freeze();
	}
	else
	{
		DrawDebugSphere(GetWorld(), Start, VelocityInHitDirection, 5, FColor::Green, false, 10.f);
		DrawDebugPoint(GetWorld(), Start, 10.f, FColor::Purple, false, 10.f);
	}
}

You could try enabling physics sub-steps to get more precise calculations.
Maybe “Enable Enhanced Determinism” could impact this as well if it can calculate it at a more fixed rate (it’s more predictable)

Thank you for the reply. I do have physics sub stepping enabled. I will try messing around a bit with those settings. I didn’t know about enable enhanced determinism, sounds promising. I will look more into that.

Hey @RigelOrionBeta. I’m not sure of this, but 800 m/s is a LOT of speed. It might be that it is detecting a collision but the object is already far away from the position. Are you sure you need to move at such high velocities? you might get away with moving slower and adding some vfx or other visual aids that make it look like the vehicles are faster than what they are actually moving. I haven’t stress tested Unreal’s collision to actually know if this is the problem you are having though.

Sometimes it also helps using sphere casts each frame instead of actual collisions, or maybe you could enable Unreal’s continuous collision detection ‘CCD’ (I’ve never used it, but it is supposed to help to detect collisions at higher speeds).

Hope this helps