[SOLVED] How to create a ‘jumpscare’ and restart the game?

It would be a child entity of your 2D screen with an image element component.

ok

it does not work :expressionless: it is supposed to enable the name of the 2d image

else if (this.enemyState === 'Attack') {
    this.enemyDestination.copy(new pc.Vec3(this.enemyTarget.getPosition().x, this.entity.getPosition().y, this.enemyTarget.getPosition().z));
    this.entity.lookAt(new pc.Vec3(this.enemyDestination.x, this.entity.getPosition().y, this.enemyDestination.z));
    this.jumpScareEntity.enabled = true;
    this.Jumpy.enabled = true;
}

If something doesn’t not work, you have to figure out why it doesn’t work.

is there a different window code
I want the window to just stop, not refresh

What do you mean with ‘just stop’? If you mean leave the jumpscare image on the screen, then remove window.location.reload();.

What about teleporting the player back to the original spot?

Yes you can do that, but what is the big difference with reloading?

It makes me lag
so I want to know how to teleport

That’s right. Is your jumpscare already working, because that’s where this topic is about?

kind of
I have an idea, player teleports into a box with jumpscare then teleports back to the start

1 Like

I just need the teleport code

Something like below.

playerEntity.rigidbody.teleport(otherEntity.getPosition());
playerEntity.rigidbody.teleport(0, 0, 0);

thanks!

A post was split to a new topic: Error reading ‘play’

I did the jumpscare! Is this what you were talking about?
https://playcanvas.com/editor/scene/1584526

Yes, perfect! You did so well that I was actually shocked too! :laughing:

2 Likes

@Brent_Reddick Great Job! Keep up the learning.

thanks!

1 Like

4 posts were split to a new topic: Hard reset project by accident