Unity学习笔记-移动物体的各种方式总结

1. Translate

Translate (plusX, plusY, plusZ)
直接通过在当前的x,y,z上加plusX, plusY, plusZ来移动物体
如果希望使移动不受帧率影响
Translate (plusX * Time.deltatime, plusY * Time.deltatime, plusZ * Time.deltatime)

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

MoveTowards(Vector3 current, Vector3 target, float maxDistanceDelta);
Moves a point current in a straight line towards a target point.

3. Lerp

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

https://docs.unity3d.com/ScriptReference/Vector3.Lerp.html

Linearly interpolates between two vectors.

Interpolates between the vectors a and b by the interpolant t. The parameter t is clamped to the range [0, 1]. This is most commonly used to find a point some fraction of the way along a line between two endpoints (e.g. to move an object gradually between those points).
按百分比移动,可用于实现物体的速度渐减/渐增移动

4. 给rigidbody一个速度

rb.velocity =

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,419评论 0 10
  • 依依以为人生这条路很长,所以她想找到这条叫“人生”的路,踏上它,开始一条最为漫长的旅途。 这是她妈妈告...
    久禾阅读 557评论 0 0
  • 你喜欢长发却留着短发,有颗明天就结婚的心,却逃不过今天依旧单身的命。像我这样长期单身的姑娘,这样的恶作剧也太可怕了...
    越小诺阅读 215评论 0 0
  • 前面的几片文章讨论了利用故事情节或场景剧本来实现理想的用户交互过程,之后从这些场景和其他来源中对需求进行定义。现在...
    Lipcui阅读 817评论 0 0
  • 一百碗不辣的凉皮 一百支两块钱的小雪生 二十瓶吐白沫的绿罐饮料 二十个长腿蚊子叮过的小红包 就可以把夏天送走 En...
    亲爱的园长阅读 198评论 3 3