The trigger wont work and I dont know why, the play touches the trigger. Another script just like it works fine, do you know the issue?
Does Not Work
var Final = pc.createScript('Final');
// initialize code called once per entity
Final.prototype.initialize = function() {
this.entity.collision.on('collisionstart', this.onCollisionStart, this);
};
//Contact
Final.prototype.onCollisionStart = function(result) {
if (result.other.name == 'Player') {
this.app.scenes.changeScene('Final');
}
};
// update code called every frame
Final.prototype.update = function(dt) {
};
// swap method called for script hot-reloading
// inherit your script state here
// Final.prototype.swap = function(old) { };
// to learn more about script anatomy, please read:
// https://developer.playcanvas.com/en/user-manual/scripting/
Works Fine
var Vent = pc.createScript('vent');
// initialize code called once per entity
Vent.prototype.initialize = function() {
this.entity.collision.on('collisionstart', this.onCollisionStart, this);
};
//Contact
Vent.prototype.onCollisionStart = function(result) {
if (result.other.name == 'Player') {
this.app.scenes.changeScene('Vent');
}
};
// update code called every frame
Vent.prototype.update = function(dt) {
};
// swap method called for script hot-reloading
// inherit your script state here
// Vent.prototype.swap = function(old) { };
// to learn more about script anatomy, please read:
// https://developer.playcanvas.com/en/user-manual/scripting/