Finding a the local position of a Hit2D

I found the

endPoint = transform.InverseTransformPoint(hit[0]).x;

However, I’m working in 2D space. I’m wondering if there is a function for this that will work with a RaycastHit2D rather than a RaycastHit.


I dont believe that there is Inverse Transform point2D in the Unity Library,
You could use regular one(Vector3) as well just use Vector3(hit2d.x,hit2d.y,0)

Vector3 endPoint = transform.InverseTransformPoint(new Vector3(hit2D.x,hit2D.y,0f));

Vector2 2dEndPoint = new Vector2(endPoint.x,endPoint.y);

Alternativley You could also use LocalTOWorld Matrix as well