Escape From The Earth 逃离地球

1、对Tags进行管理
设置一个全局的类,类似如下:
public class Tags:MonoBehaviour{
public const string player="Player";
}
调用Tags.player
2、发送消息
unity中每一个对象都有SendMessage,BroadcastMessage,SendMessageUpwards 三个发送消息的方法!
具体使用方法参考:http://www.cnblogs.com/MrZivChu/p/sendmessage.html
3、利用iTween绘制路径线
public Transform[] points;
public void OnDrawGizmos()
{
iTween.DrawPath(points);
}

4、人物移动
;
public Vector3 targetPosition;
void Update()
{ //获得人物前进方向
Vec tor3 moveDir = targetPosition - transform.position;
transform.positon += moveDir.normalized * moveSpeed * Time.deltaTime;
}
5、获得障碍物生成的点
因为地形是不平整的,有高低起伏的,所以我们的障碍物生成点是根据比率来算的
Vector3.Lerp(prePoint,nextPoint,(z-prePoint.z) / (nextPoint.z - prePoint.z)) // Lerp会根据第三个参数(比率)来算出上一个点和下一个点之间的一个点
6、动画队列
animation.Play("Idle1");
animation.PlayQueued("Idle2");//把Idle2动画加入队列,也就是说,当Idle1播放完,就去播放Idle2的动画
7、获得触摸方向(鼠标)
public enum TouchDir
{
None,
Left,
Right,
Top,
Bottom
}
Vector3 lastMouseDown = Vector3.zero;
TouchDir GetTouchDir()
{
))
{
lastMouseDown = Input.mousePosition;
}
))
{
Vector3 mouseUp = Input.mousePosition;
Vector3 touchOffset = mouseUp - lastMouseDown;
|| Mathf.Abs(touchOffset.y) > )
{
)
{
return TouchDir.Right;
}
)
{
return TouchDir.Left;
}
)
{
return TouchDir.Top;
}
)
{
return TouchDir.Bottom;
}
}
}
return TouchDir.None;
}
8、根据动画时长计时完成动画播放
bool slide = true;
float allTime = 1.73f;//此动画总共时间为1.73s
;
void LateUpdate()
{
if (slide)
{
initTime += Time.deltaTime;
if (initTime > allTime)
{
initTime = ;
slide = false;
}
animation.Play("slide");
}
}
9、人物跳跃

Escape From The Earth 逃离地球的更多相关文章
- (29)Why Earth may someday look like Mars
https://www.ted.com/talks/anjali_tripathi_why_earth_may_someday_look_like_mars/transcript00:12So whe ...
- 五、Pandas玩转数据
Series的简单运算 import numpy as np import pandas as pd s1=pd.Series([1,2,3],index=['A','B','C']) print(s ...
- HDU 3605 Escape(状压+最大流)
Escape Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Sub ...
- Help Me Escape (ZOJ 3640)
J - Help Me Escape Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:32768KB ...
- ZOJ- 3640 Help Me Escape
Help Me Escape Time Limit: 2 Seconds Memory Limit: 32768 KB Background If thou doest well, ...
- ZOJ3640-Help Me Escape
Help Me Escape Time Limit: 2 Seconds Memory Limit: 32768 KB Background If thou doest well, ...
- Help Me Escape ZOJ - 3640
Background If thou doest well, shalt thou not be accepted? and if thou doest not well, sin lieth ...
- Escape HDU - 3605(归类建边)
Escape Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Subm ...
- HDU 3605 Escape (网络流,最大流,位运算压缩)
HDU 3605 Escape (网络流,最大流,位运算压缩) Description 2012 If this is the end of the world how to do? I do not ...
随机推荐
- bzoj4836 [Lydsy2017年4月月赛]二元运算
Description 定义二元运算 opt 满足 现在给定一个长为 n 的数列 a 和一个长为 m 的数列 b ,接下来有 q 次询问.每次询问给定一个数字 c 你需要求出有多少对 (i, j) ...
- 0001-BUGIFX-Magento-Zend-Framework-1-PHP5.6.patch
It is from the full Github-Gist: Bugfix for Zend Framework 1 in Magento (>= 1.7..) + PHP 5.6 http ...
- python 3+djanjo 2.0.7简单学习(四)--Django视图
1.概念 Django 中的视图的概念是「一类具有相同功能和模板的网页的集合」.比如,在一个博客应用中,你可能会创建如下几个视图: 博客首页——展示最近的几项内容. 内容“详情”页——详细展示某项内容 ...
- assert函数和捕获异常
assert函数: C语言和C++都有一个专为调试而准备的工具函数,就是 assert()函数. 这个函数是在C语言的 assert.h 库文件里定义的,所以包含到C++程序里我们用以下语句: #in ...
- Qlikview 数据加载方法罗列
以下是通常会用到的数据加载的方法,供大家参考: 1. 从文件加载: Data: Load *,RowNo() as InputKey; SQL SELECT ID,TEST,DATECREATED F ...
- PHP调试小错误汇总
1.中文显示乱码 解决:加上header('Content-type:text'); 2.Unable to find the wrapper "https 解决:到php.ini中把ext ...
- jquery 筛选元素 (2)
.add() 创建一个新的对象,元素添加到匹配的元素集合中. .add(selector) selector 一个字符串表示的选择器表达式.找到更多的元素添加到匹配的元素集合. $("p&q ...
- react中密码自动填充及解决火狐浏览器,360浏览器记住密码后,密码框自动填充终极解决方案
先直接上核心代码如下: 在火狐浏览器,360浏览器,初次加载,bug长这样: 如果你想通过生命周期componentDidMounted等生命周期进行置空操作都是不行的,这可能是浏览器自带的特性记住密 ...
- Cloudera Manager 安装 CDH5
文档说明 本文是针对Linux CentOS6服务器与CDH5.15的安装手册. 关于CDH和ClouderaManager CDH(Cloudera's Distribution, includin ...
- javascript遍历方法总结
forEach 循环 JavaScript诞生已经有20多年了,我们一直使用的用来循环一个数组的方法是这样的: for (var index = 0; index < myArray.lengt ...