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

posted @ 2015-04-30 14:18  HONT  阅读(4782)  评论(0编辑  收藏  举报