1.在自身的前后:
Vector3.Dot (transform.forward, target.position-transform.position)
返回值为正时,目标在自己的前方,反之在后方
2.在自身的左右:
Vector3.Dot(transform.right, target.position-transform.position)
返回值为正时,目标在自己的右方,反之在左方
3.在自身上下:
Vector3.Dot(transform.up, target.position-transform.position)
返回值为正时,目标在自己的上方,反之在下方
4、Vector3 worldPosition = transform.TransformPoint ( Vector3 relativePosition )
将transform
的坐标转化为基于世界坐标系的坐标,相对位置为relativePosition(世界坐标系)
5、
// Calculate a position between the points specified by current and target, moving
// no farther than the distance specified by maxDistanceDelta.
//
// 参数:
// current:
// The position to move from.
//
// target:
// The position to move towards.
//
// maxDistanceDelta:
// Distance to move current per call.
//
// 返回结果:
// The new position.
public static Vector3 MoveTowards(Vector3 current, Vector3 target, float maxDistanceDelta);
计算从current点,到target点的距离s,
如果距离s大于等于maxDistanceDelta,则最终点为从current开始,方向为current到target的方向,距离为maxDistanceDelta,最终计算出来的点
如果距离s小于maxDistanceDelta,则最终点为从current开始,方向为current到target的方向,距离为s,最终计算出来的点