找回密码
 立即注册
楼主: 小米

[脚本] Unity3D用lerp+Mathf.PingPong的方式让本物体缓动

[复制链接]
发表于 2013-4-25 20:28 | 显示全部楼层 |阅读模式
  1. using UnityEngine;
  2. using System.Collections;

  3. public class Move : MonoBehaviour {
  4.     public  float durning;
  5.     public Vector3 toPos;
  6.    
  7.     private Transform t;
  8.     private Vector3 oriPos;
  9.     private float lerp;
  10.    
  11.     // Use this for initialization
  12.     void Start () {
  13.         t = transform;
  14.         oriPos = t.localPosition;
  15.     }
  16.    
  17.     // Update is called once per frame
  18.     void Update () {
  19.         lerp = Mathf.PingPong(Time.time, durning) / durning;
  20.         t.localPosition = Vector3.Lerp(oriPos, toPos, lerp);
  21.     }
  22. }
复制代码
发表于 2013-5-19 01:54 | 显示全部楼层
具体有什么作用啊··
发表于 2016-8-25 15:36 | 显示全部楼层
很棒的帖子..
发表于 2016-11-28 15:34 | 显示全部楼层
666666666666666666
发表于 2016-11-28 15:34 | 显示全部楼层
666666666666666666
发表于 2017-2-20 16:39 | 显示全部楼层
好帖就是要顶
发表于 2017-2-20 17:24 | 显示全部楼层
真心顶
发表于 2017-2-20 17:04 | 显示全部楼层
难得一见的好帖
发表于 2017-2-20 16:49 | 显示全部楼层
很好哦
发表于 2017-2-20 17:13 | 显示全部楼层
LZ真是人才
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-4-29 16:13 , Processed in 0.115727 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表