When you cast a primitive, Raycast.distance gives you the distance the primitive traveled along the direction before the first collision. If I want to then calculate the position of the primitive where the collision occurred, I need to do something like this: contactPosition = castStartPosition + castDirection * hit.distance
For SphereCast this is straightforward, since you pass the center of the sphere directly to the function, but what about CapsuleCast? It accepts the points of the bottom and top spheres defining a capsule, so what is the position of it?
If I add vector castDirection * hit.distance to both points, the result will be two points defining a new capsule, but then I need to end up with one point that I can assign to the transform. Does unity treat it like capsuleCenter = (capsulePoint1 + capsulePoint2) * 0.5f - colliderCenterOffset
, or is there more to it?