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,关节运动 不在这里讲解

     


    小结

     

     

  • 相关阅读:
    经典算法排序——希尔排序
    查找算法总结
    Anddroid HttpService
    经典排序算法——直接选择排序
    [置顶] 获取Android手机上音乐播放器状态
    经典排序算法——归并排序
    Android锁屏未读短信,未接电话
    经典排序算法——冒泡排序
    经典排序算法——快速排序
    linux下同时存在当静态库和动态库同名
  • 原文地址:https://www.cnblogs.com/01zxs/p/10134115.html
Copyright © 2011-2022 走看看