Ok, this is a really stupid mistake on my part. Change your function call to this.changeScenes(), with the s at the end. Guess this is what happens when I try to type code on mobileš. Edited my original post as well.
EDIT -
Just so you can troubleshoot this issue on your own next time, when you get an error message saying function is not defined, then just scroll through your list of functions in the script, and double check your call. More often than not, youād be able to fix it yourself.
Yes, there was this mistakeā¦
very interesting situation, right now it showing me that its ānot foundā, but I inserted id numbers of scenes, and parsed codesā¦
Can you double check the numbers?
Hello! Is there also a console error?
Hello,
I don`t see console mistakesā¦=(
Do you already know what exactly is ānot foundā?
I think it cant find the scenes, because I see this report after clicking on buttons, but I`m not sure exactlyā¦
Do you have a project link?
Great news, I will try to reboot my laptopā¦
Sorry it was the example project. Do you have a project link? Maybe I can see a mistakeā¦
Yes, ofcourse:
https://playcanvas.com/editor/scene/916895
Pls let me know what do you think about it, I`m very new in it.
I also donāt have a lot of experience, but I can always help to find out where things go wrong.
Are you sure this code is oke:
this.loadScene (this.sceneId, function () {
// Once the new scene has been loaded, destroy the old one
oldHierarchy.destroy ();
});
I canāt find where you set this.sceneId.
Try to change this:
ChangingScenes.prototype.changeScenes = function() {
// Get a reference to the current root object
var oldHierarchy = this.app.root.findByName ('Root');
// Load the new scene. The scene ID is found by loading the scene in the editor and
// taking the number from the URL
// e.g. If the URL when Scene 1 is loaded is: https://playcanvas.com/editor/scene/475211
// The ID is the number on the end (475211)
this.loadScene (this.sceneId, function () {
// Once the new scene has been loaded, destroy the old one
oldHierarchy.destroy ();
});
};
To this:
ChangingScenes.prototype.changeScenes = function(sceneId) {
// Get a reference to the current root object
var oldHierarchy = this.app.root.findByName ('Root');
// Load the new scene. The scene ID is found by loading the scene in the editor and
// taking the number from the URL
// e.g. If the URL when Scene 1 is loaded is: https://playcanvas.com/editor/scene/475211
// The ID is the number on the end (475211)
this.loadScene (sceneId, function () {
// Once the new scene has been loaded, destroy the old one
oldHierarchy.destroy ();
});
};
If you add me to the project I can help better.
1 Like
Yes, you helped me, it works
But now I figured out that I don`t have abilities to come back to my first page after chosing one scene among those three that I haveā¦
Great!
You need a button or something on every scene to go back to the āscene selectionā scene. I donāt know what kind of game you want to make, so I donāt know what is the best way in your case.
1 Like
Yes, because of your help I have base, I have some ideas of how to use that to finish my first step.
Thank you, now I have what to study!!!
1 Like
Sorry about the delay in my response @Ivan_Stratiichuk. My idea would be to have a selection scene in your game, that leads to every other scene. Then, in all the other scenes, you can have a back to selection button. Thatās what I normally do in my games.
1 Like
Hi @Leonidas I am trying to create a PlayCanvas scene that switches between two senes using a button and am trying to open the scene you posted as an example:
https://playcanvas.com/editor/scene/916857
However, it is not opening. Thanks ahead for any help.
Hi @Ian_Curtis,
The way I set this up is by having a scene manager that transports itself between scenes. To ensure that it only gets loaded once, I made an initialization scene that loads the first scene of my choosing and then uses app events fired by the buttons to change scenes from there.
Check out :
https://playcanvas.com/project/756176/overview/scene-manager
To see it at work.
2 Likes