How to do a clean game reset and destroy all data in app

When a game ends I want to destroy everything within the old game and load a fresh version of it.

If I use I’ve noticed that there are still event listeners active in the scene.

Is there a clean way to destroy everything in the app except the app itself?

Or would it be recommended to destroy the app and create a new one?

Thank you.

Sounds like you are best off refreshing the page to be honest.

The app.root node shouldn’t be destroyed. The scene’s root node is actually a child of app.root. That graph node should be destroyed instead.

In terms of leftover event listeners, please remember that anything that listens to an events needs to be responsible for removing the event too when it is destroyed. For pc.scripts, that means listening for the destroy event and removing the listeners in the callback.