Transform.InverseTransformPoint

Cambiar al Manual
public Vector3 InverseTransformPoint (Vector3 position);

Descripción

Transforma la position del espacio del mundo al espacio local.

Esta función es esencialmente lo opuesto de Transform.TransformPoint, el cual es utilizado para convertir de espacio local al espacio del mundo.

Tenga en cuenta que la posición de vuelta es afectada por escala. Utilice Transform.InverseTransformDirection si está tratando con vectores de dirección en vez de posiciones.

// Calculate the transform's position relative to the camera.
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform cam; public Vector3 cameraRelative;

void Start() { cam = Camera.main.transform; Vector3 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"); } }

public Vector3 InverseTransformPoint (float x, float y, float z);

Descripción

Transforma la posición x, y, z del espacio del mundo al espacio local. Lo opuesto de Transform.TransformPoint.

Tenga en cuenta que la posición de vuelta es afectada por escala. Utilice Transform.InverseTransformDirection si usted está tratando con direcciones.

// Calculate the world origin relative to this transform.
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Start() { Vector3 relativePoint = transform.InverseTransformPoint(0, 0, 0);

if (relativePoint.z > 0) print("The world origin is in front of this object"); else print("The world origin is behind of this object"); } }