Hi, my script is supposed to reset my character to its original position when it falls below a certain point. My debugging shows that everything should be working fine, but it just doesn’t do anything. It notices when it gets below y = -1, it gets the correct values for what it should reset to but the setPosition doesn’t seem to do anything. Here’s the code:
var Death = pc.createScript('death');
// initialize code called once per entity
Death.prototype.initialize = function() {
this.startPos = this.entity.getPosition().clone();
};
// update code called every frame
Death.prototype.update = function(dt) {
if (this.entity.getPosition().y < -1) {
//console.log("dead"); //debug
//console.log(this.startPos.y); //debug
this.entity.setPosition(this.startPos.x, this.startPos.y, this.startPos.z);
}
};
// swap method called for script hot-reloading
// inherit your script state here
// Death.prototype.swap = function(old) { };
// to learn more about script anatomy, please read:
// http://developer.playcanvas.com/en/user-manual/scripting/