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

For what you need an example? I don’t have a jumpscare example unfortunately.

ok you mean like a picture pops up with a loud noise and sound effect?

Yes, I would start with that. You can improve it when you are done.

bu I dont have a 2d image of the 3d model monster what do I do?

You can search for a look-alike image. You can also create one yourself, for example start with a screenshot of your 3D model.

ok I got my image now how do I make it appear when the monster attacks in the enemy ai script ya made

I have already shared the code. Replace your current window.location.reload(); with it.

ok thanks

I want it to trigger the jumpscare, wait one second, then stop or refresh the window

I use 5 seconds in my code example above.

ok uh do I make this a seperate script or do I put it in enemt ai?

As far I have seen you use this somewhere in your enemy AI script.

would the image be a sprite or a 2d screen?

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?