[SOLVED] Disabling/Enabling Entities Code Causes Freezing

I’ve been trying to get my game so that when the player’s x position is less than the end point’s x position, the game switches from the level entity to the result entity. Basically a simple scene switch. I’ve tried putting this code inside the main level entity, and in the global root entity, but it keeps on freezing when you reach the end goal. I’m pretty sure it’s because of the way I arranged my code, but I’m not sure where I went wrong. Could someone point out my mistake and please fix this issue?

Link To Editor: https://playcanvas.com/editor/scene/892021

Could someone help please? All I need is a script that actually works.

It’s the weekend so people are less likely to be at their computers to be able to look at a project in detail.

It would also help if you can list the steps to reproduce the error in your project and roughly which code or files to look at so people don’t have to spend time to actually get to the issue.

1 Like

Yaustar is right, steps to reproduce the error are very helpful and some pointers to your code in question.

For your issue I think the problem is that when you reach the end of the level, you go ahead and disable the Main Levels entity. But that entity includes as child the Camera as well:

image

And you enable the Result Screen which doesn’t contain any camera entity. So essentially you stop having any enabled camera to render your scene, leading to your game being frozen.

Add a Camera to your Result Screen entity and your issue will be fixed.

1 Like

Yeah, I think that was the problem. I’ll see if it changes anything.

Ok, I’ll try to specify the steps next time.

Issue’s Fixed! Thank you @Leonidas & @yaustar.

1 Like