How do I perform a sphere trace at a single point?

Hi everybody!

I have a ball in the game I am making, and would like to test for objects touching it using a trace. SphereTraceByChannel almost does what I want, but if I set the start and end points to the same vector, it tests against a capsule shape, not a sphere.

In general, my confusion is this: why doesn’t a SphereTraceByChannel test against a perfect sphere when the start and end points are the same? Can I not perform a “sweep” with a sphere at a single point?

Here’s a picture of what I’m talking about (trace with same start/end):

I have my own physics simulation I am trying to integrate, and it depends on being able to determine contact with other surfaces along the ball’s surface. Since I can’t get the sphere trace to align with the ball’s shape, the simulation is broken.

Any suggestions? Please let me know if I can provide any additional information. Thanks!

Update:

Just in case weary internet travelers arrive here, I noticed some odd behavior about sphere traces that may be interesting:

SphereTraceByChannel will perform an overlap test if the start and end points are the same, but return an incomplete hit result. In this case, ImpactLocation and Location will be the same point since it is no longer a sweep.

To get the expected (depenetrated) Location result, you need to do a line trace from the start point following the negated normal of the SphereTraceByChannel hit result to determine the contact point of the sphere trace. You can then use that result to determine how much the sphere would need to move to no longer penetrate the contacting surface.

Hope that helps somebody.

You better use a SphereCollision instead of Tracing. You have BeginOverlap, OnComponentHit, EndOverlap…It’s useless if you use a Trace and make the Start and End at the same location.

As it turns out, I was mislead by a display issue and not a collision issue. The sphere trace at a point actually does what I expected, however, there is a bug with how it draws the debug capsule for the trace.

The picture I posted shows the incorrect capsule draw, but when I tested it manually it actually is colliding where it is supposed to along the sphere. Strange…

My approach makes it difficult to use the overlap / hit events, since the calculations are done synchronously per frame, but I’ll see if I can maybe alter my approach to accommodate this. Thanks!