zoukankan      html  css  js  c++  java
  • 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,关节运动 不在这里讲解

     


    小结

     

     

  • 相关阅读:
    zlib 用了很多次,这次记下来
    boost 1.53 比1.52 ASIO bug 修正
    64位汇编
    js C++
    这个split 不错 我喜欢的
    布6月26日至28日将在旧金山召开2013年Build大会
    asio同步模式和异步模式
    vc6 编译boost
    windows 编译mongodb 2.4
    ajaxToolKit中 的折叠面板用法Accordion
  • 原文地址:https://www.cnblogs.com/01zxs/p/10134115.html
Copyright © 2011-2022 走看看