天天看點

Unity向量投影使用

Unity向量投影使用

官方例圖

測試:

Unity向量投影使用

code:

public Transform point1;
public Transform point2;
public Transform humanPoint;
public Transform targetPoint;

void Start()
{
}

void Update()
{
    targetPoint.position = point1.position + Vector3.Project(humanPoint.position - point1.position, point2.position - point1.position);
}      

官方論壇擴充閱讀LINK