线性操作:伤害门。
生成游戏对象
using UnityEngine;
using System.Collections;
public class CreateCubes : MonoBehaviour {
// Use this for initialization
void Start () {
}
float timer = 0.0f;
// Update is called once per frame
void Update () {
timer += Time.deltaTime;
if (timer>3)
{
timer -= 3;
GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Cube);
obj.transform.position = new Vector3(0,0.5f,0);
obj.AddComponent<MoveDoor>();
}
}
}
对象移动
using UnityEngine;
using System.Collections;
public class MoveDoor : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
gameObject.transform.Translate(gameObject.transform.forward * Time.deltaTime);
}
}
判断是否受到伤害
using UnityEngine;
using System.Co