Changing scene/levels

Hey

I have an issue with level changing, and it’s quite weird, don’t know what happened:

I have two separated scenes, when you finish the first one, the second one was loaded and there was no problem, in fact, I have a published demo version which worked just fine:

(you just have to grab the dragger to the other extreme 3 times)

this morning I was working on another script (the canvas avobe), different from the loader script, then suddenly an error kept on coming after loading :

http://playcanvas.com/editor/scene/419937/launch

if you do the same thing as before, scene changes, but now we have this error:

“playcanvas-stable.js:21047 Uncaught Error: GUID already exists in graph”

Is this related to the level changing? Somethig about the camera? Please help! :frowning:

That error means that you are adding an Entity into the hierarchy twice. Could be a couple of possibilities.

You could be loading the scene more than once and adding it into the hierarchy twice.

Or you could be creating an entity and adding it more than once into the hierarchy.

You should be able to breakpoint that error and see where you problem occurs.

Thank you @dave, working on it

I think I may be doing wrong loading levels. I used app.root.destroy(); and then loaded the level, but I think there are still some Childs in the hierarchy, or at least some stuff loaded. How can I check that and how can I fix it?

Never destroy app.root.
Btw, app.root - is not root entity of your scene (I know it is weird, and I’m personally not happy with that too, but it is the way it is).

So all roots of scenes go as children to app.root, so you can destroy them from there.

@max I see, going to check. Thank you!

So, I changed the way I swapped levels and seems to be working better now.

Now, I renamed the Root Entity and, when changing levels, delete it and load the new one.

By the way, when I do this, some scripts seems from the previous scene seems to be still loaded, in fact in some computers I’ve detected playback is slower as I navigate through scenes, (it does not happen when I load the scenes separatedly). Is there something else I’m missing?


So i’ve checked the VRAM in the profiler.

SCENE 2 directly

SCENE 2 through SCENE 1

Second scene has the 18 MB from scene 2 and the 30MB from scene 1 (not shown here)… how can I free that?

When talking about assets, then you need to clear them yourself.
You can use tags on assets to mark specific assets, and then find them using findByTag. Then unload and release associated resources with assets. It is an asset.resource - you need to remove usually.

2 Likes

Ok, gonna check it out! thank you!