【发布时间】:2015-11-06 04:09:42
【问题描述】:
我正在制作一个简单的僵尸生存游戏。这段代码有问题,它只检测到一个触发器,而不是另一个。
#pragma strict
var health = 100;
var attack = 10;
var delay = 5;
var scream : AudioClip;
var player : Collider;
function OnTriggerEnter () {
if (player.gameObject.tag == "ZombieFlame") {
gameObject.Find("Flame").SendMessage("OnTriggerEnter");
}
if (player.gameObject.tag == "Zombie") {
Attack ();
}
if (health == 0) {
Debug.Log("Die!");
Lose ();
}
}
function Attack () {
health -= attack;
Debug.Log("Under attack!");
audio.PlayOneShot(scream);
yield WaitForSeconds(delay);
Loop ();
}
function Loop () {
OnTriggerEnter ();
}
function Lose () {
this.active = false;
}
我的脚本检测到“ZombieFlame”,但没有检测到“Zombie”。 gameObjects 已经有标签,所以我不知道发生了什么。它也像 Trigger 一样被检查。
【问题讨论】:
-
“那个Transform已经有了标签”——我不明白这是什么意思。
-
您使用的所有游戏对象的具体配置是什么?
-
我的英语不好...我想说“转换已经有标签”
标签: unity3d unityscript