0
public class green : MonoBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "BLUE")
{
Destroy(other.gameObject);
gm.mylife -= 1;
}
}
}
public class gm : MonoBehaviour
{
public GameObject blue;
static public bool tr = false;
public Text life;
public static int mylife = 0;
void Start()
{
makebox();
}
void makebox()
{
StartCoroutine("timedelay");
}
IEnumerator timedelay()
{
yield return new WaitForSeconds(3f);
Debug.Log("sdfaDF");
GameObject br = Instantiate(blue, new Vector3(-6, -2, 0), Quaternion.identity) as GameObject;
makebox();
}
void Update()
{
life.text = (mylife.ToString());
}
}
我做了一個藍色的盒子,當它碰到東西並且有-1分時被銷燬。 它是在(-2,2)的位置。 然後我做了一個預製。但預製不起作用。它只是在與原點相同的位置創建的。 我想讓我的預製摧毀並且也是-1。 我該如何解決它? 請幫我...預製不同於它的原點
謝謝你的幫助...但是,我給了延遲...也許它可以解決,給克隆的預製標籤...我檢查克隆的預製沒有標籤... ㅠㅠ – fluentparrot