I would like help with this death script please

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.

@DinoCalebProductions Would you be able to provide a link to your project?

sure

https://playcanvas.com/editor/scene/1379118

this is the link

by the way if you hit play then you have to go though the door

in order to see the monster

@DinoCalebProductions I would like to show you how to get to the places where your script is failing. I am not getting your movement to work real great and would like to have you clean up some of these errors so we can proceed. This is a screen shot of your errors.

During the first run of your game you see this. This is a great place to start figuring out what is wrong with your project. To the left of the red error there is a yellow link. Click on it and it will bring you to here.

image

If you have a look there is a cursor position noted. this.app.root.<<<<Maybe but the next puzzling part is findbyName and your script name. So that would be your next place to look after you fix this. I don’t see that you are using the variable cameraPath in your script so I am not sure why it is needed or this script is maybe unfinished.

Second error was located by using the same method above. Here is the script that it showed an issue in.

In this case I think it is pointing to root. The other thing that I noticed is that you have a bunch of items you are trying to find. findByTag this query function will search all graph nodes for tag names in the list. I have no idea about what it will do with this.other and this. Here is the API reference to the function call. Entity | PlayCanvas API Reference

Is it possible you want to use findByName instead? Not sure looking at the code.

It’s looks like you have a great start to your game. I am still not actually sure what your question is. Is it possible you want to detect a collision with an enemy and respond to it? please help me clarify what needs to be looked at next when you correct these issues.

Thank you very very much for explaining this to me.

I must have to wait till tomorrow to fix it because it is rather late where I live, but thank you very much for your help.

what I am trying to achieve is for the player to teleport to a new scene when the trigger touches its rigid body. I also want it to ignore any other rigid body it may collide with unless it’s the player.

that’s for the death tele script.

for the other script what I was hoping to achieve was to get the entity/fishy to move on the camera path only when the player triggers it.

I will have to work on it tomorrow but thank you very very much for this explanation and for showing me what the yellow words do as well.

Have a nice night!