this is the sample scene that i just placed at the end to give you an example. As you can see, for some reason the player get duplicated multiple times and this sometimes happen randomly throughout the levels which causes the errors to appear.
haha I actually started playcanvas two days ago, and I realised that there are not many tutorials about it on coding. So I get whatever I can on youtube tutorials that are made years ago.
I recommend using the example project here to see how to change scenes with the current version of PlayCanvas: Changing scenes | Learn PlayCanvas
Without seeing the project, my best guest is that you are loading the new scene multiple times. Please share a link to the project and it be easier for people in the forums to look at
It looks like in your project, you are were referring to the oldHierarchy in a different function and should be calling the callback instead. This resulted in an error (where you should have gotten an error message) and the old hierarchy not being deleted.
sorry, but can I know which parts you have updated cause I cannot see the difference haha. I would like to learn for future reference, also which part did I do it wrong?
NextScene.prototype.loadScene = function (sceneName, callback) {
// Get the path to the scene
var scene = this.app.scenes.find(sceneName);
// Load the scenes entity hierarchy
this.app.scenes.loadSceneHierarchy(scene.url, function (err, parent) {
if (!err) {
callback();
} else {
console.error(err);
}
});
};
Looks like that is a different error that should be looked at. I would also change the NextScene code so that it can’t load the scene more than once per level
That error only happens when a duplicated entity made, at least that happens everytime when the duplication occurs. As for the NextScene code, I thought its already loading the scene once per level?
Very helpful. I learned programming by following a video tutorial series (making a chess and checkers game) that was made in the same way. Because you can follow every step in the process, you slowly start to understand the connections.
Oh wow, I really didnt expect this to happen at all. This was actually a test for a job interview, in which I tried to finish as best I could and submit it. I mostly use unity therefore this was very new to me to use and I was testing things out, and there was sadly not many tutorials on playcanvas. This video you just sent was really helpful and I have learned alot from it, thank you.