zoukankan      html  css  js  c++  java
  • Vector3.Lerp 插值

    Vector3.Lerp 插值

    static function Lerp (from : Vector3to : Vector3t : float) : Vector3

    Description描述

    Linearly interpolates between two vectors.

    两个向量之间的线性插值。

    Interpolates from towards to by amount t.

    按照数字t在from到to之间插值。

    t is clamped between [0...1]. When t = 0 returns from. When t = 1 returns to. When t = 0.5 returns the average of from and to.

    t是夹在 [0...1]之间,当t = 0时,返回from,当t = 1时,返回to。当t = 0.5 返回from和to的平均数。

    // Animates the position to move from start to end within one second
    //在1秒时间动画位置移动从from开始到to结束。
    var start : Transform;
    var end : Transform;
    function Update () {
    	transform.position = Vector3.Lerp(start.position, end.position, Time.time);
    }

    另一个例子:

    // Follows the target position like with a spring
    //像弹簧一样跟随目标物体
    var target : Transform;
    var smooth = 5.0;
    function Update () {
    	transform.position = Vector3.Lerp (
    	transform.position, target.position,
    	Time.deltaTime * smooth);
    }

    插值的使用很平凡,比如在网络坐标的传送中,每间隔一个fixupdate传送一次的坐标在使用过程中就需要使用到插值的方法达到平滑移动的效果。
  • 相关阅读:
    GUI编程
    网络编程
    线程池详解_3
    多线程详解_2
    注解和反射_1
    多线程详解_1
    javaEE简要总结
    MarkDown使用教程简单介绍
    com.sun.xxx.utils不存在问题的解决
    解决npm install安装慢的问题
  • 原文地址:https://www.cnblogs.com/88999660/p/2893094.html
Copyright © 2011-2022 走看看