粒子系统 DontDestroyOnLoad

Particle system DontDestroyOnLoad

我在游戏中追求的是当玩家和行星发生碰撞时,玩家会消失,留下粒子系统形式的爆炸效果。紧接着(可能半秒)我想让 "game over" 场景出现在它的位置上。这是我目前所拥有的:

void OnCollisionEnter2D (Collision2D col) {
    if (col.gameObject.tag == "enemyPlanet") {
        Instantiate (explosion, thingToMove.transform.position, thingToMove.transform.rotation);
        ui.gameOverActivated ();
        Destroy (gameObject);
        am.rocketBang.Play();
        Application.LoadLevel ("gameOverScene2");
    }
}

我遇到的问题是粒子出现但没有像爆炸那样移动。我想这要么是因为游戏结束场景正在加载,要么是因为它的位置是正在被摧毁的玩家(thingToMove)。

我试过这个:

public void Awake() {
    DontDestroyOnLoad (transform.gameObject);
}

但同样的事情发生了。如果是因为玩家正在被摧毁,我该如何让它在玩家被摧毁时出现在玩家的位置?

我希望这是有道理的,并提前致谢。

您可以使用Invoke方法在指定延迟后结束游戏。

void OnCollisionEnter2D (Collision2D col) {
    if (col.gameObject.tag == "enemyPlanet") {
        Instantiate (explosion, thingToMove.transform.position, thingToMove.transform.rotation);
        ui.gameOverActivated ();
        am.rocketBang.Play();
        Invoke( "over", 2.0f );

    }
}

void over(){
    Destroy (gameObject);
    Application.LoadLevel ("gameOverScene2");
}