移动:
Position:
直接修改位置数据
关键词 |
函数 |
说明 |
Position |
||
Translate |
Transform.Translate(Vector3 dir) |
【匀速】朝着一个方向,一直移动。 (dir * speed 可以控制速度) 适合键盘控制物体上下左右运动 |
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 |
Vector3 v = Vector3.zero; Vector3.SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime) |
平滑的从A逐渐移动到B点。适用于相机的跟随 (当前位置,目标位置,xx,耗时) |
AddForce |
Rigidbody.AddForce(Vector3.right * Force, ForceMode.Force); |
对该物体施加某个方向的力 |
MovePosition |
Rigidbody.MovePosition(Vector3 target) |
刚体在物理效果的作用下,向着目标移动 |
velocity |
Rigidbody.velocity = new Vector3(1, 0, 0); |
刚体的速度(X轴方向的速度为1) |
其余的动画运动,ITween,关节运动 不在这里讲解 |