[SOLVED] Create a Jumpscare

I need help with something I want to make a jumpscare where if the player is touching the enemy they teleport to a box that has a jumpscare in it.

How it Works:

Player --------> Enemy
Player touches enemy
Player teleports into box
Plays sound and jumpscare occurs

Hi @Mason_Rocchio! I see you already know how to do it. With which part you need help?

I did it look

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

Teleport.prototype.onCollisionStart = function (result) {
    if (result.other.parent.parent.name === 'SCP-096') {
        this.entity.rigidbody.teleport(new pc.Vec3(-0.026,-19.459,-1.498));

the problem is I don’t know where to put the code for the sound to play.

I guess below the line where you teleport the entity.

thats strange it wont teleport me

Can it teleport below the map because thats where the jumpscare is

Yes, that should be possible. I suggest to play your sound at that point, to find out if your script is working as it should.

It is not the sound is in the player that plays when the monster collides. It just wont teleport.

You want the link to the Project?

Yes please.

Alright here:

Editor: PlayCanvas | HTML5 Game Engine

Game: PlayCanvas | HTML5 Game Engine

I think result.other.parent.parent.name === "Monster" should just be result.other.name === "Monster".

It worked thanks!

1 Like