言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Transform.InverseTransformPoint

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public function InverseTransformPoint(position: Vector3): Vector3;
public Vector3 InverseTransformPoint(Vector3 position);
public def InverseTransformPoint(position as Vector3) as Vector3

Description

ワールド空間からローカル空間へ position を変換します。Transform.TransformPointとは逆の機能になります

返される位置情報はスケールに影響されていることに注意してください。方向に関する情報を扱う場合はTransform.InverseTransformDirectionを使用します。

	// 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");
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Transform cam = Camera.main.transform;
    public Vector3 cameraRelative = cam.InverseTransformPoint(transform.position);
    void Example() {
        if (cameraRelative.z > 0)
            print("The object is in front of the camera");
        else
            print("The object is behind the camera");
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public cam as Transform = Camera.main.transform

	public cameraRelative as Vector3 = cam.InverseTransformPoint(transform.position)

	def Example() as void:
		if cameraRelative.z > 0:
			print('The object is in front of the camera')
		else:
			print('The object is behind the camera')

public function InverseTransformPoint(x: float, y: float, z: float): Vector3;
public Vector3 InverseTransformPoint(float x, float y, float z);
public def InverseTransformPoint(x as float, y as float, z as float) as Vector3

Description

ワールド空間からローカル空間へ x, y, z を変換します。Transform.TransformPointとは逆の機能になります

返される位置情報はスケールに影響されていることに注意してください。方向に関する情報を扱う場合はTransform.InverseTransformDirectionを使用します。

	// Calculate the world origin relative to this transform.

	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");
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Example() {
        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");
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Example() as void:
		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')