How to get the center of a CapsuleCast or SphereCast on collision

I have a CapsuleCast being projected from my previous position to my current position in order to detect if I have collided with anything.
If I have collided, I want to teleport the player to the CapsuleCast center from when it returned a hit.point.

Since the CapsuleCast will be the same size as my players capsule, and since my players pivot point is at the center, which is also the capsule colliders center on my player, if I can just get the center of the CapsuleCast from when it hit a collider, I can just teleport the player to the CapsuleCast center which will align my players capsule with the CapsuleCast. I can then offset it by a tiny bit to bump the character a bit more away from the collider it is colliding with.

The CapsuleCast hit.point could be anywhere when it hits a collider. It could be somewhere near the top of the CapsuleCast collider, or somewhere near the middle. I have no idea where the hit.point is relative to the CapsuleCast collider.

I can think of a possible different way to get the results I want, such as instead of a CapsuleCast I can maybe just use a gameobject with a capsule collider and imitate what the CapsuleCast is doing by moving the capsule collider from the players previous position to the players current position, and have a check for OnCollisionEnter and such, and now I’ll have the center since I have the gameobject as a reference, however I do not know how accurate this would be compared to the CapsuleCast, and there may be issues with objects needing rigidbodies and such. Perhaps instead of OnCollisionEnter id use a physics.CapsuleCheck instead. Not sure.

Any help would be appreciated.
Thank you!

Today I happened to stumble upon this thread http://forum.unity3d.com/threads/analyzing-and-optimizing-unity-sphere-capsule-casts.233328/ which said that the RaycastHit distance value given by SphereCast and CapsuleCast is actually “… the actual distance the sphere should travel before it hits the hitpoint. This means that if you traveled from the cast origin in the cast direction by the distance provided in the RaycastHit info, you would get the origin of the sphere to which the hitpoint lies on the edge of.”

I tested it and it seems to be correct. So you can basically just do this to get the center of a SphereCast or CapsuleCast

Origin is the origin of your cast, directionCast is the direction of your cast, and the hitInfoDistance is the RaycastHit distance value returned by the cast.

public static Vector3 SphereOrCapsuleCastCenterOnCollision(Vector3 origin, Vector3 directionCast, float hitInfoDistance)
{
    return origin + (directionCast.normalized * hitInfoDistance);
}

Example usage

RaycastHit hitInfo;
if(Physics.SphereCast(transform.position, .5f, transform.forward, out hitInfo))
{
    Vector3 centerOnCollision = SphereOrCapsuleCastCenterOnCollision(transform.position, transform.forward, hitInfo.distance);
}