美文网首页零基础Unity学习笔记
Unity学习笔记-移动物体的各种方式总结

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

作者: pirateH | 来源:发表于2018-05-01 23:33 被阅读22次

    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 =

    相关文章

      网友评论

        本文标题:Unity学习笔记-移动物体的各种方式总结

        本文链接:https://www.haomeiwen.com/subject/fpsgbttx.html