Unity 移动 和 旋转 [小结]

【移动


 Position:

说明:

  直接修改位置数据


 Translate:

说明:

  【匀速】朝着一个方向,一直移动。 (dir * speed 可以控制速度)适合键盘控制物体上下左右运动

函数:

  Transform.Translate(Vector3 dir)


MoveTowards:

说明:

  【匀速】朝着目标移动。(当前位置,目标位置,最大速度)

函数:

  Vector3.MoveTowards(Vector3 current, Vector3 target, float maxDistanceDelta);


 Lerp:

说明:

  【线性插值】朝着目标移动。(当前位置,目标位置,速度)

函数:

  Vector3 Lerp(Vector3 a, Vector3 b, float t);


Slerp:

说明:

  【球形插值】朝着目标移动。(当前位置,目标位置,速度)

函数:

  Vector3 Slerp(Vector3 a, Vector3 b, float t);


SmoothDamp:

说明:

  平滑的从A逐渐移动到B点。适用于相机的跟随(当前位置,目标位置,xx,耗时)

函数:

  Vector3 v = Vector3.zero;

  Vector3.SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime)

 


AddForce:

说明:

  对该物体施加某个方向的力

函数:

  Rigidbody.AddForce(Vector3.right * Force, ForceMode.Force);


MovePosition:

说明:

  刚体在物理效果的作用下,向着目标移动

函数:

  Rigidbody.MovePosition(Vector3 target)


 velocity: 

说明:

  刚体的速度(X轴方向的速度为1)

函数:

  Rigidbody.velocity  = new Vector3(1, 0, 0);

 


其余的动画运动,ITween,关节运动 不在这里讲解

 


 

小结

 

 

posted @ 2018-12-17 21:38  激情1995  阅读(979)  评论(0编辑  收藏  举报