当我的物体接触到扳机时,它被摧毁并感染了新的感染。然后在 4 秒后它应该返回到之前的状态。通过协程延迟。但没有延迟。对象立即创建
public GameObject boxPrefab; 公共游戏对象 visibalBoxPrefab;
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Flashlight")
{
Destroy(boxPrefab);
Debug.Log("DESTROY");
var cloneBox = Instantiate(visibalBoxPrefab, boxPrefab.transform.position, Quaternion.identity);
Destroy(cloneBox, 2f);
StartCoroutine(Break(cloneBox));
}
}
IEnumerator Break(GameObject cloneBox)
{
Instantiate(boxPrefab, cloneBox.transform.position, Quaternion.identity);
yield return new WaitForSeconds(4f);
}
只想知道我哪里错了