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 逃离地球的更多相关文章

  1. (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 ...

  2. 五、Pandas玩转数据

    Series的简单运算 import numpy as np import pandas as pd s1=pd.Series([1,2,3],index=['A','B','C']) print(s ...

  3. HDU 3605 Escape(状压+最大流)

    Escape Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Sub ...

  4. Help Me Escape (ZOJ 3640)

    J - Help Me Escape Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:32768KB ...

  5. ZOJ- 3640 Help Me Escape

    Help Me Escape Time Limit: 2 Seconds      Memory Limit: 32768 KB Background     If thou doest well, ...

  6. ZOJ3640-Help Me Escape

    Help Me Escape Time Limit: 2 Seconds      Memory Limit: 32768 KB Background     If thou doest well, ...

  7. Help Me Escape ZOJ - 3640

    Background     If thou doest well, shalt thou not be accepted? and if thou doest not well, sin lieth ...

  8. Escape HDU - 3605(归类建边)

    Escape Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

  9. HDU 3605 Escape (网络流,最大流,位运算压缩)

    HDU 3605 Escape (网络流,最大流,位运算压缩) Description 2012 If this is the end of the world how to do? I do not ...

随机推荐

  1. 【洛谷5251】[LnOI2019] 第二代图灵机(线段树+ODT)

    点此看题面 大致题意: 有单点修改数字和区间着色两种修改操作,询问你某段区间内包含所有颜色且数字和最小的子区间的数字和,或某段区间内没有重复颜色且数字和最大的子区间的数字和.数据随机. \(ODT\) ...

  2. A. Kyoya and Colored Balls_排列组合,组合数

    Codeforces Round #309 (Div. 1) A. Kyoya and Colored Balls time limit per test 2 seconds memory limit ...

  3. IntelliJ IDEA环境使用

    转:https://blog.csdn.net/zwj1030711290/article/details/80673482 https://blog.csdn.net/zrc199021/artic ...

  4. linq 和lambda查询

    EF 查询的两种 写法. linq 方法 或者 lambda方法 其中 ,只有tolist()的时候,才会真正的 在数据库中执行. 如果没有 tolist 方法,那么province1是 iqueab ...

  5. Linux(二) - Unix&Linux 基本概念

    主机 = 内核 + 实用工具 内核(kernel) 当计算机启动时,计算机要经历一系列动作,这些动作构成了引导过程.引导过程的最后一个动作是启动一个非常复杂的程序,该程序就被称为内核(Kernel) ...

  6. P1725 琪露诺

    P1725 琪露诺 单调队列优化dp 对于不是常数转移的dp转移,我们都可以考虑单调队列转移 然而我们要把数组开大 #include<cstdio> #include<algorit ...

  7. CharSquence 接口的作用,多态以增强String

    CharSquence 接口的作用,多态以增强String,CharSquence 可以多态定义 String StringBuffer StringBuilder.

  8. codeforces757E. Bash Plays with Functions(狄利克雷卷积 积性函数)

    http://codeforces.com/contest/757/problem/E 题意 Sol 非常骚的一道题 首先把给的式子化一下,设$u = d$,那么$v = n / d$ $$f_r(n ...

  9. Go HTTP模块处理流程简析

    Go语言提供完善的net/http包,用户使用起来非常方便简单,只需几行代码就可以搭建一个简易的Web服务,可以对Web路由.静态文件.cookie等数据进行操作. 一个使用http包建立的Web服务 ...

  10. linux 特殊命令(一)

    1.ifconfig 网卡配置:ifconfig  [网络设备] [参数] 1) up 启动指定网络设备/网卡. 2) down 关闭指定网络设备/网卡.该参数可以有效地阻止通过指定接口的IP信息流, ...