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

     


    小结

     

     

  • 相关阅读:
    【Python应用:基于PyQt5文本识别】调用百度AI对一张或多张图片、文件夹中的图片和屏幕区域截图进行识别(PDF转Word 小意思)
    【Ubuntu搭建Django编程环境】:创建python虚拟开发环境和配置pip国内镜像源
    23种设计模式上篇
    荷兰国旗问题
    文件复制多份
    mybatis批量更新
    数组小和
    常见排序算法
    福尔摩斯的约会
    小明上学
  • 原文地址:https://www.cnblogs.com/01zxs/p/10134115.html
Copyright © 2011-2022 走看看