JavaScript? Public Function Inversetransformpoint(position: Vector3): Vector3;
C#? public Vector3 inversetransformpoint(Vector3 position);
Description Description
Transforms position from World space to local space. The opposite of Transform.transformpoint.
Transforms the position from world coordinates to local coordinates. The opposite of Transform.transformpoint.
Note that the returned position are affected by scale. Use the transform.inversetransformdirection if you is dealing with directions.
Note that the return position is affected by scaling. If you are dealing with directions use transform.inversetransformdirection.
Javascript:
Calculate the transform ' s position relative to the camera.var cam = Camera. Main. transform; var camerarelative = Cam. Inversetransformpoint(transform. Position); if (camerarelative. Z > 0) print ("The object is in front of the camera"); Else Print ("The object is behind the camera");
C#:
UsingUnityengine;UsingSystem.Collections;PublicClass ExampleClass: Monobehaviour{Public Transform Cam= Camera.Main.Transform;public Vector3 camerarelative = cam. Inversetransformpoint (Transform. Positionvoid example ({if Span class= "Br0" > (Camerarelative. Z > 0) print ( "the Object is in front of the camera ") else print ( "The object is behind the camera" ) }} /span>
JavaScript? Public Function inversetransformpoint(x: float, y: float, z: float): Vector3;
C#? public Vector3 inversetransformpoint(float x, float y, float z);
Description Description
Transforms the position x, Y, z from World space to local space. The opposite of Transform.transformpoint.
Transform position x, Y, z from world coordinates to local coordinates. The opposite of Transform.transformpoint.
Note that the returned position are affected by scale. Use the transform.inversetransformdirection if you is dealing with directions.
Note that the return position is affected by scaling. If you are dealing with directions use transform.inversetransformdirection.
Javascript:
//Calculate the world origin relative to this Transform. relativepoint = transform. Inversetransformpoint (00 0 if (Relativepoint. Z > 0) print ( "the World origin was in front of the This object ") else print ( "the world origin was behind of this object"
C#:
UsingUnityengine;UsingSystem.Collections;PublicClass ExampleClass: Monobehaviour{void example ({relativepoint = transform. Inversetransformpoint (0, 0, 0 if (Relativepoint. Z > 0) print ( "the World origin was in front of the This object ") else print ( "the world origin was behind of this object" ; }} /span>
? Transform
Transform. Inversetransformpoint and transform. Transformpoint, what's going on?
One is to transform its own coordinates into world coordinates, one is to transform the world coordinates to its own coordinates.
For example, there is a 3,3,3 point in the coordinates of object A. You want to know that this point should be used in the world coordinates transformpoint
And there's a point in the world coordinates. You want to know if it's a position in the coordinates of object A, you should use Inversetransformpoint.
In fact, it's a conversion between the position of the object in the editor and the position of the object within the object.
Transform.inversetransformpoint Reverse Transform Point