Hey,
I have adapted the changing scenes code from the tutorial here :
https://playcanvas.com/editor/scene/475237
When I click the button with the game I want to load, I get the following 2 errors -
playcanvas-stable.min.js:1020 GET https://s3-eu-west-1.amazonaws.com/apps.playcanvas.com/WDSG7KhI/undefined.json 403 (Forbidden)
__game-scripts.js:26 Error while loading scene https://s3-eu-west-1.amazonaws.com/apps.playcanvas.com/WDSG7KhI/undefined.json: 403
I am unable to figure out what I am doing wrong, Please help.
My script is as follows -
var ChangingScenes = pc.createScript('changingScenes');
ChangingScenes.attributes.add("basketballSceneId", {type: "string", default: "0", title: "Basketball Scene ID"});
ChangingScenes.attributes.add("footballSceneId", {type: "string", default: "0", title: "Football ID"});
ChangingScenes.attributes.add("archerySceneId", {type: "string", default: "0", title: "Archery ID"});
ChangingScenes.attributes.add("Basketball", {type: "entity"});
ChangingScenes.attributes.add("Football", {type: "entity"});
ChangingScenes.attributes.add("Archery", {type: "entity"});
ChangingScenes.prototype.initialize = function()
{
// Change scenes in 1 second
this.Basketball.element.on('touchstart', this.startBasketballGame, this);
this.Basketball.element.on('mousedown', this.startBasketballGame, this);
this.Football.element.on('touchstart', this.startFootballGame, this);
this.Football.element.on('mousedown', this.startFootballGame, this);
this.Archery.element.on('touchstart', this.startArcheryGame, this);
this.Archery.element.on('mousedown', this.startArcheryGame, 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 (this.sceneId, function () {
// Once the new scene has been loaded, destroy the old one
oldHierarchy.destroy ();
});
};
ChangingScenes.prototype.startBasketballGame = function()
{
this.changeScenes(this.basketballSceneId);
console.log("in");
};
ChangingScenes.prototype.startFootballGame = function()
{
this.changeScenes(this.footballSceneId);
};
ChangingScenes.prototype.startArcheryGame = function()
{
this.changeScenes(this.archerySceneId);
};
ChangingScenes.prototype.loadScene = function (id, callback) {
// Get the path to the scene
var url = id + ".json";
// Load the scenes entity hierarchy
this.app.loadSceneHierarchy(url, function (err, parent) {
if (!err) {
callback(parent);
} else {
console.error (err);
}
});
};
Link to my project is here below -
https://playcanvas.com/project/678223/overview/tabletopgames