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!