unity 移动物体到指定位置的四种方法
来源:互联网 发布:印刷自助报价系统源码 编辑:程序博客网 时间:2024/05/24 01:13
方法1:使用Vector3.MoveTowards
</pre><pre name="code" class="csharp">void Update () {float step = speed * Time.deltaTime; gameObject.transform.localPosition = Vector3.MoveTowards(gameObject.transform.localPosition, new Vector3(10, -3, 50), step);}
void Update () {float step = speed * Time.deltaTime; gameObject.transform.localPosition =new Vector3(Mathf.Lerp(gameObject.transform.localPosition.x, 10, step),Mathf.Lerp(gameObject.transform.localPosition.y, -3, step),Mathf.Lerp(gameObject.transform.localPosition.z, 50, step));//插值算法也可以}
方法3:使用iTween
iTween.MoveTo(m_UIbgCamera, iTween.Hash("x", -20, "y", -3, "z", 50, "time", 1.0, "islocal", true ));
方法4:使用协程
StartCoroutine(MoveToPosition());
IEnumerator MoveToPosition() { GameObject m_UIbgCamera = GameObject.Find("UI/FengMian/UIbgCamera"); while (m_UIbgCamera.transform.localPosition != new Vector3(-5, -3, 50)) { m_UIbgCamera.transform.localPosition = Vector3.MoveTowards(m_UIbgCamera.transform.localPosition, new Vector3(-20, -3, 50), 10 * Time.deltaTime); yield return 0; } }
0 0
- unity 移动物体到指定位置的四种方法
- Unity移动物体到鼠标点击位置
- unity的三种物体移动方法
- 我的Unity(1)一点一滴 鼠标点击任意位置,物体移动到该位置。
- Unity中物体如何移动到鼠标点击位置
- Unity 变换物体位置的几种方法
- 我的Unity(2)一点一滴 鼠标拖动物体,物体在三维中移动到该位置。
- Unity3D中移动物体位置的几种方法
- Unity中移动物体的几种常用方法
- Unity 几个物体移动的方法
- unity移动物体的方法及区别
- Unity3D之实现点击地形使物体移动到指定位置
- Unity3d物体运动到指定位置
- Unity-->实现物体的移动
- unity里面物体的移动
- 鼠标点击物体移动到该位置
- 移动鼠标到指定位置
- [Unity3d ]物体自动移动到指定点
- 将Berkeley DB基本数据库操作封装成类
- oracle常用的数据字典
- 【redis】redis介绍
- 【BZOJ3875】【Ahoi2014】骑士游戏 SPFA处理有后效性动规
- 关于UITextField和UITextView的placeholder
- unity 移动物体到指定位置的四种方法
- ios设置cookie
- java 垃圾回收调优
- codeforces 295D Greg and Caves
- jQuery: 在this的环境中使用选择器
- RecyclerView的基本用法 (一)
- 很好用的上传代码
- CodeForces 407B Long Path
- 关于oracle中的decode的使用