How can I make that the scene restarts if the player passes trough the ground?

Hi all! I have a problem in my game.
The thing is that there is an enemy that follows the player, but when that enemy is near the ground, the player is pushed until it ends up in the ground.

Is there any way to detect that and make the scene to restart?

The way you’ve explained your problem sounds like the player sinks into the ground when in contact with your enemy for whatever reason. Unless this is intentional, sounds like it is a collision bug.

More importantly, we need some screenshots, video or gif would be better, to get a better idea of your issue.

There it is the video. I used a tilemap for the ground

ah perfect, never would have guessed the game was taking place underwater.

From the vid alone, it looks like the shark is a trigger collider, and the player switches between regular and trigger collision depending on their damage state. If you aren’t doing anything fancy with switching collision types though, I’m not sure. You could try changing the collision detection of the rigidbody to “continous” if it isn’t.

If you want to detect collision when stuck in a wall either way, one way might be to have a child object with a smaller trigger collider within your player character, and have a script in that child object that adds time in OnTriggerStay. If time is past a certain threshold, reset the player.