Another problem with switching scenes

https://playcanvas.com/editor/scene/1307980

When I load the next (9th) scene per se, it works fine. If I load it by reaching the goal from the previous level/scene, there is a problem with the particles; namely that it won’t play.

But there’s something weird going on: If you shoot and the particles play while going to the next level, in the next level, at first, you cannot shoot, but the particles play. Then, after a few tries, the shooting works normally again. (Sorry for the commas)

Thx in advance for any help and fixing suggestions

Hi @SayHiToMePls,

Do you still have trouble with this issue?

Yes

1 Like

So, what can be the problem ?

Not sure, it plays fine if I launch your link above, I am stuck in a room shooting green balls.

Wait a moment, I’m gonna change it so you can go to the next level

Actually, you should go through that door that has a slight offset texture. It has no rigidbody

Good, seems to work, shooting balls in the new level. There is an error in one of your scripts that should look at:

But the funny thing is that if I launch scene 9, it works normally

Maybe somewhere when changing scenes you aren’t removing input or event listeners?

That won’t happen automatically, and it’s a common problem.

Could you please take a look at the Shoot.js script? The error is at line 39

I have the theory that when I reach the goal of a level, the hierarchy does not switch everything out perfectly and therefore, does those problems. I’m referring to nextScene.js

Yes, most likely there are callbacks, methods that should be manually removed that are still in place.

Sorry it’s too big of a project to take a look now, I will try and do so later. If I find something I’ll let you know.

I’m a bit in a hurry with my development right now, since I have to let some players test the entire game. And my thesis about this game is due next Thursday. Please, take a look at the cause of the error asap, if I can’t find it

Or can you please tell me how to entirely switch scenes, including the settings?

Use the following two methods in a sequence, the first for the hierarchy and the second for the settings:

https://developer.playcanvas.com/api/pc.SceneRegistry.html#loadSceneHierarchy

https://developer.playcanvas.com/api/pc.SceneRegistry.html#loadSceneSettings

So, you mean first loadSceneHierarchy and right underneath that function loadSceneSettings?

Do I not have to write something inside those functions or is it optional?

For loading the scene yes, as you say, one after the other. The functions accept an optional callback which you can use to execute code after each method finishes loading.

1 Like

And what are the attributes for, because in the docs, they aren’t even used

I mean the function(err, entity)

You mean in the callback? The err is the type of error, if any error exists.

Entity is the parent entity of the new scene hierarchy I think, it’s not documented below.