I have searched lots of forum but failed to understand the use of these function . I only found that transform.TransformPoint converts the local to global and other function vice versa .Please tell me where to use these functions in unity
Thanx In advance
Please tell me where to use these
functions
That’s like asking, “where do I use Mathf.Sin().” These functions are just tools that can be used to solve problems.
A common use for Transform.InverseTransformPoint() is to find out the relationship of one object to another. Given object A facing some arbitrary direction and another object, B. If I do:
var pos = A.InverseTransformPoint(B.position);
I now have B’s position in the local space of A. So if pos.x is negative, B will be to A’s left. If pos.y is positive, B will be above A. If pos.z is negative, B will be behind A.
As for TransformPoint(), say I had a cube with an arbitrary position, rotation, and scale and wanted to know the world position of the bottom of the cube. I could do:
var pos = Cube.TransformPoint(Vector3.down * 0.5);
This will return the bottom of the cube at any particular rotation no matter what the local scale. That is both functions deal with position, rotation and scale.