How do i get local Hit position of Raycast on a collider

HI, so I’m trying to build an AutoAim functionality for my Fps shooting game, The idea is that when user will point close to Enemy, it will automatically snap towards the center, for this purpose i put a collider in Enemy and detecting it with Raycast and a layer. I want to detect weather the Ray hitting the collider is on which side (Right or left) so that i can subtract the distance from midpoint and rotate my player’s camera.

To Get position of RayHit i am using Hit.point , But issue is that it is returning value in WorldSpace, and value changes every time player moves.

alt text

Collider that I’m using to detect is always looking at camera and doesn’t matter if i rotate around the enemy it will always be looking at camera

I want to get RayCastHit position on Collider not in worldspace

Vector3 localHit = transform.InverseTransformPoint(hit.point);

Transform.InverseTransformPoint