Switching scenes

Hey y’all
I am a very new beginner and I’m having a lot of trouble with changing scenes. I’ve tried other people’s comments, the handbook, and youtube but none of them helped so I have literally nothing to show. I’m on the verge of giving up. I just want to click on a button and have it bring me to the next scene. Does anyone have code for that?

Maybe you can refer to this link.

Loading Scenes | Learn PlayCanvas

1 Like

I’ve already tried that :confused:

Is it possible to share the project?

I don’t think it would matter. I have no working code as of now.

Hi @twdomldev and welcome!

You can find all information you need on the page that @Hizard shared, but I can understand it can still be difficult if you are a beginner. Maybe the steps below can help you a little more on your way.

  • You need an entity with an element component and make sure the option ‘Use Input’ is enabled.

  • The entity also need a script that has to code below in the initialize function of it.

this.entity.element.once('click', function() {
    this.app.scenes.changeScene('Some Scene Name');
}, this);
  • Make sure you replace Some Scene Name with the correct name of the scene.

It still doesn’t work for me. There is no error message but when I click the button in the preview, nothing happens.

If you share the editor link of your project someone can take a look.

Make sure that the ‘Use Input’ option on the element component of the button is true.

1 Like