It’s my code,
,
Debug.Log(“vWorld:”+goTarget.transform.position);
Debug.Log(“vLocal:”+goTarget.transform.InverseTransformDirection(goTarget.transform.position));
The output is same,not i want.Who know’s how to do?
The local position is already available as a property of transform, you don’t have to recalculate it:
If you really want to, or if your situation is somehow different in a way that forces you to recalculate it, the correct way would be to either multiply the world position with the inverse model matrix, stored as Transform.worldToLocalMatrix, or you could use Transform.InverseTransformPoint.
Transform.InverseTransformDirection is for directions, not points.