[SOLVED] I wanna make a teleporter, but i dont know how

Yes, the problem is probably because the parentheses before and after the script name. Can you confirm that @Gabriel_Dobrzynski? Does the script works as expected after your fix?

1 Like

Yes, @thebosser24 added me to the game, I changed some stuff and It works now.

i tried it and it doesnt work https://playcanvas.com/editor/scene/1099897

1 Like

What do you expect and what is the actual result @thebosser24?

1 Like

i expect to teleport but instead, I run into it

im sorry, it just isnst working


this is what is says when i load into it

Im So CONFUSED!

I’m unable the check your project at this moment so can you check and confirm this please? I assume the script is on the rectangle?

yes

they have it all

does the rectangle have to be a wall or could it peek from the ground




image
image
IDK heres pictures.

Looks like your curly brackets are in the wrong places. Does this help?

Teleport.prototype.initialize = function () {
    this.entity.collision.on('collisionstart', this.onCollisionStart, this);

    this.teleportPoint = this.app.root.findByName('TeleportPoint');
};


i did that and this is what was said

I don’t see a script on your rectangle and the rigidbody component is disabled.

On this?


and i fixed the rigidbody thing

I didn’t mean replace this whole script just to fix the initialize function.
But here is the whole script for you to replace :slight_smile:

var Teleport = pc.createScript('teleport');

// initialize code called once per entity
Teleport.prototype.initialize = function () {
    this.entity.collision.on('collisionstart', this.onCollisionStart, this);

    this.teleportPoint = this.app.root.findByName('TeleportPoint');
};

Teleport.prototype.onCollisionStart = function (result) {
    if (result.other.rigidbody) {
        result.other.rigidbody.teleport(this.teleportPoint.getPosition());
    }
};
2 Likes

Im back, this is weird :confused: It should let you teleport, have you put the script on the rectangle? Also, if you have then can you send a link?

IT WORKS but it said this

1 Like

Thank you
(should i ignore this mess when i go into it?)

Uh, this could not affect the game or affect the game badly. It’s just better to try and fix it because then the game might not work as expected. :face_with_raised_eyebrow:

1 Like

how do i fix it?

:frowning:

It looks like there is no collision component anymore. Try to debug by yourself first and stop posting short messages.

1 Like