一.
Vector3 newForward=Vector3.Slerp(transform.forward,new Vector3(0,1,0),Time.deltaTime);
球行插值函数:即一个向量在一定时间间隔内绕着起点旋转到终止向量位置
参数一:起始位置向量
参数二:终止位置向量
参数三:从起始向量转动到终止向量的时间,当为1时则完成
如:for(int i=1;i<=10;i++)
{
Vectors to=Vector3.Slerp(new Vector3(-1.0f,1.0f,0.0f),new Vector3(1.0f,1.0f,0.0f),0.1f*i);
//画出直线,以便观察
Debug.DrawLine(Vector3.zero,to,Color.yellow);
}
二.
float relativeDirection=Vector3.Dot(transform.forward,target..transform.forward);
计算两个向量角度大小函数
参数:两个参数都是向量,并计算该两个向量的的夹角值
三.
transform.position = Vector2.MoveTowards (this.transform.position, new Vector2 (player.position.x, this.transform.position.y), Time.deltaTime);
将一个点的位置移动到指定位置,返回一个Time.deltaTime/1.0f等份点坐标
参数一:起始位置
参数二:终止位置
参数三:从起始位置平移动到终止位置的时间,当为1时则完成
四.
this.transform.Rotate (Vector3.up*Time.deltaTime*rotateSpeed,Space.Self);
将游戏对象自定义在一定空间旋转角度
参数一:在指定向量绕其转动角度,值愈大,旋转角度愈大
参数二:指定的旋转空间,Space.Self指自身游戏空间
五.
float newPosY = Mathf.SmoothDamp(transform.position.y, target.transform.position.y,
ref yVelocity, smoothTime);
- 当前坐标
- 目标点
- 移动速度
- 缓动参数,越小越快地接近目标
- 最大速度
- 上次调用该方程的时间