Hi @Leonidas
Quick follow-up, hopefully, related to this post. The new scene loads and the old scene is destoryed but I am now getting an error saying:
[movement.js?id=55699174&branchId=cadc9749-917a-43fd-95df-8ba3c255d79f:121]: Cannot set properties of undefined (setting ‘x’)
movement.js is attached to an entity for the new scene and x is referring to a force applied to the entity within the update method, this.force.x. The x is first defined in the initialize method within movement.js, this.force = new pc.Vec3(). It appears that initialize does not run prior to the update method, thus the error?
I have tried looking through the discussion boards and believed I should load the scene hierarchy but this turned chaotic, similar to this thread (code for my project below). Multiple entities load and still throwing the same error. Plus, when I try to change scenes after this point the old scene is no longer destroyed. The old thread talked about bind being the problem but referred to it as an event??
In short, how can I have initialize in movement.js run prior to update?
Also, I believe that with bind(this) on the load scene function will be called again when another scene is loaded, thus the old scenes not being destroyed??
Any help is appreciated!
from this script
setTimeout(function() {
//console.log(go.responseText.split('\t',7)[0]);
var old = this.app.root.findByName('Root');
old.destroy();
if(go.responseText.split('\t',7)[0] == 0){
//console.log(go.responseText.split('\t',7)[0]);
//var sceneItem = this.app.scenes.find("Scene Name");
//load scene hierarchy of next scene
this.app.scenes.loadSceneHierarchy('1234829.json', function (err, entity) {
if (!err) {
//ball is name of entity with movement.js
var e = this.app.root.find("ball");
} else {
// error
}
}.bind(this));
this.app.scenes.loadScene('1234829.json', function(){
}.bind(this));
}else{
alert(go.responseText);
}
}.bind(this), 1000);