这次的脚本主要写得是鼠标左键右键的功能,子弹的发射和人物的瞬移(并不是完美)功能。
public GameObject man;
public bool move;
public GUIText movetime;
public float h;
public float op;
public int T = 3;
private System.Timers.Timer time = new System.Timers.Timer (5000);//设定时间经过多少秒后触发
public bool move;
public GUIText movetime;
public float h;
public float op;
public int T = 3;
private System.Timers.Timer time = new System.Timers.Timer (5000);//设定时间经过多少秒后触发
void Awake() {
man = GameObject.Find ("player");
time.Elapsed += new System.Timers.ElapsedEventHandler (run);//设定触发的函数
time.Start();//设定开启
}
man = GameObject.Find ("player");
time.Elapsed += new System.Timers.ElapsedEventHandler (run);//设定触发的函数
time.Start();//设定开启
}
void FixedUpdate () {
movetime.text = "瞬移次数:" + T;
if (T > 0) {
if (Input.GetMouseButtonDown (1)) {//如果调用鼠标右键执行
op = man.transform.position.x;
move = true;
T -= 1;
}
}
if (move) {//具体的瞬移方式