Reload scene when dead

What i want is that when life is zero, that the scene just restarts, but i can't find out how to do this

i now have something like this:

var playerLife = 100;

if (playerLife < 1){ //Reload scene }

In Unity 5.0 and later

// place this at the top of your file
using UnityEngine.SceneManagement;

// then call this to restart game
void hardRestartGame() {

Application.LoadLevel() is now obsolete, so you should use SceneManager.LoadScene() instead. You can pass in an argument of SceneManager.GetActiveScene() to just reload the current scene.

Note that unlike the Application class, the SceneManager class is not directly in UnityEngine, so you’ll need to add this line to your imports at the top of your source file: using UnityEngine.SceneManagement;.

if (playerLife < 1) Application.LoadLevel(Application.loadedLevel);

I had this problem too. I wanted to destroy the player object and than restart the scene, but then i realized, that i was calling the code from object that was already destroyed. So just create empty object and attach the code to it. Hope this might help someone :slight_smile:

Unity 2019.4
Edit: This is C#
Edit 2: also have the script named “TriggerControl” otherwise it’s gonna give you an error
This is really late but I just want to post this, put this script in to the object that you want to reload the scene when the player and the object collide, make sure the player or the object have a rigidbody.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class TriggerControl : MonoBehaviour
   private void OnCollisionEnter(Collision other)
        if (other.gameObject.tag == "Player")