private GameObject score;
private Score scoreScript;
private GameObject tank;
private TankController tc;
public bool isEnemy = false;
void Start () {
score = GameObject.Find ("Score");
scoreScript = score.GetComponent<Score> ();
tank = GameObject.Find ("Tank");
tc = tank.GetComponent<TankController>();
}
void Update () {}
void OnTriggerEnter(Collider other)
{
Destroy (this.gameObject);//子弹碰到即消失
if (other.name.Equals ("Tank") && isEnemy) {
tc.health -=1;
}
if (other.name.Equals ("Tank Enemy")&& !isEnemy) {
scoreScript.score += 1;//子弹碰到敌人就分数加一
Destroy(other.gameObject);
}
}
坦克小战结尾篇之子弹
最新推荐文章于 2023-05-21 11:57:16 发布