下边是介绍transform.InverseTransformPoint,
transform.InverseTransformDirection和 transform.InverseTransformVector
下边附上代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InversePoint : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Debug.Log(Vector3.forward);
Debug.Log("转换后的点" + this.transform.InverseTransformPoint(Vector3.forward));
Debug.Log("转换后的方向(不受缩放影响)" + this.transform.InverseTransformDirection(Vector3.forward));
Debug.Log("转换后的方向(受缩放影响)" + this.transform.InverseTransformVector(Vector3.forward));
}
// Update is called once per frame
void Update()
{
}
}
就是将世界坐标转变成相对本地坐标系的点
本地转世界坐标系,受到缩放影响
Debug.Log("本地转世界点" + this.transform.TransformPoint(Vector3.forward));
Debug.Log("本地转世界方向(不受缩放影响)" + this.transform.TransformDirection(Vector3.forward));
Debug.Log("本地 转 世界方向" + this.transform.TransformVector(Vector3.forward));