Hello, I would really appreciate it if one of you could help with this problem that has been bugging me for a long time.
You see a while back ago one of you had helped me with my script death teleport, I believe it was either @Albertos or @yaustar, and I thank you very much but I have a another problem with this script that I cant figure out so I will really like some help please.
this is my script. NOTE: I changed the name to Death Teleport 2
DeathTeleport2.attributes.add("sceneName", {type: "string", default: "", title: "Scene Name to Load"});
// initialize code called once per entity
DeathTeleport2.prototype.initialize = function() {
this.entity.collision.on('triggerenter', function(event) {
if(entity.name('Player') === true){
// it's the player, do the things you normally do
this.loadScene('Dead');
}
}, this);
};
DeathTeleport2.prototype.onTriggerEnter = function(result) {
entity.rigidbody.linearVelocity = pc.Vec3.ZERO;
entity.rigidbody.angularVelocity = pc.Vec3.ZERO;
// change the scene
if(result.entity.name('Player') === true){
this.loadScene(this.sceneName); // loadScene function doesn't exist in the script
}
};
// update code called every frame
DeathTeleport2.prototype.update = function(dt) {
};
DeathTeleport2.prototype.loadScene = function (sceneName) {
// Get a reference to the scene's root object
var oldHierarchy = this.app.root.findByName ('Root');
// Get the path to the scene
var scene = this.app.scenes.find(sceneName);
// Load the scenes entity hierarchy
this.app.scenes.loadSceneHierarchy(scene.url, function (err, parent) {
if (!err) {
oldHierarchy.destroy();
} else {
console.error(err);
}
});
};
// swap method called for script hot-reloading
// inherit your script state here
// StartGame.prototype.swap = function(old) { };
// to learn more about script anatomy, please read:
// https://developer.playcanvas.com/en/user-manual/scripting/
type or paste code here
So you see what I want the script to do Is to teleport the player when the player touches whatever collider it has.
And I only want it to work if it touches the player and not any other rigid body.
That’s what you guys had helped me with but now this happens when I start.
p.s.the path trigger is another problem I will fix later.
And when the enemy touches me it also gives me this error.
By the way this is my monster up close. I modeled him myself using Monster mash demo. =)
so now you see what it does and sadly I have no Idea what it is. I tried looking at the code highlight, and I experimented but my attempts unfortunately failed.
So I came here to ask for help.
In return for your favor I will also try to help anybody I can on this forum to.
Thank you very much for reading and sorry I wrote so much.