Hi all
I have just started using PlayCanvas and am having some coding difficulties.
If I try to call a function (such as this.entity.model.hide()), when I try to launch the game an error message saying “Uncaught TypeError” comes up. How do I fix this?
Thanks, disabling the entity works.
I looked at the tutorial project for changing scenes and tried to write my own code but it isn’t working for me… here’s my code:
var ChangingScenes = pc.createScript('changingScenes');
ChangingScenes.attributes.add("sceneName", {type: "string", default: "", title: "Scene Name to Load"});
ChangingScenes.prototype.initialize = function(dt) {
};
// update code called every frame
ChangingScenes.prototype.update = function(dt) {
};
ChangingScenes.prototype.loadScene = function (sceneName) {
// Get a reference to the scene's root object
var oldHierarchy = this.app.root.findByName ('Root');
console.log('function working');
// Get the path to the scene
var scene = this.app.scenes.findByName ('Untitled2');
// Load the scenes entity hierarchy
this.app.scenes.loadSceneHierarchy(scene.url, function (err, parent) {
if (!err) {
oldHierarchy.destroy();
} else {
console.error(err);
}
});
};
ChangingScenes.prototype.loadScene();
// swap method called for script hot-reloading
// inherit your script state here
// ChangingScenes.prototype.swap = function(old) { };
// to learn more about script anatomy, please read:
// http://developer.playcanvas.com/en/user-manual/scripting/