沿着路线寻路
2016-05-14 08:15
330 查看
沿着路线寻路
using UnityEngine; using System.Collections; public class InfoUI : MonoBehaviour { public Transform player;//获取玩家 public Transform[] path;//获取要去地方的点 int count1 = 0;//计时 // Use this for initialization void Start () { } // Update is called once per frame void Update () { Vector3 movedir = path[count1].position - player.position; //判断超过点数清零 if (movedir.magnitude<1) { count1++; if (count1>=path.Length) { count1 = 0; } } //方向 player.transform.rotation = Quaternion.Slerp(player.transform.rotation, Quaternion.LookRotation(movedir), Time.deltaTime * 5); //速度 player.transform.Translate(movedir.normalized * 5 * Time.deltaTime, Space.World); } }
相关文章推荐
- 【华为OJ】【056-统计大写字母个数】
- hdu 5676-ztr loves lucky numbers
- 分享iOS开发常用(三方类库,工具,高仿APP,实用网站,技术干货)
- shell实现输入密码显示星号
- 如何禁止GridView滑动
- MySQL删除数据后磁盘空间的释放情况
- 返回出现次数最多的数字
- yii2.0邮箱发送
- HDU 4757 Tree
- 发几个美女,证明博客还活着
- ASP.NET MVC最新特性
- 小代码 题目
- Spring MVC实现大文件下载功能
- 小代码js
- 消除Xcode7中Directory not found for option 'XXX'警告
- 线段树 例一
- 小代码
- 小代码
- 小代码
- 小代码