Skip to main content
added 28 characters in body
Source Link
OKprogrammer
  • 522
  • 1
  • 7
  • 20

Add this script into your enemy. It will reset the scene which in theory will bring the player back to start. Remember to call the UnityEngine and UnityEngine.SceneManagement API services at the start. Also, make sure to have the player tag on the player, so the scene won’t restart if any GameObject collides with the enemy.

  // Initiates when something collides with enemy
        void OnTriggerEnter2D(Collider2D collider) {
    
        if (collider.gameObject.CompareTag(“Player”)) {
           {
              SceneManager.LoadScene(SceneManager.getActiveScene().buildIndex);
           }
        }

Add this script into your enemy. It will reset the scene which in theory will bring the player back to start. Remember to call the UnityEngine and UnityEngine.SceneManagement API services at the start. Also, make sure to have the player tag on the player, so the scene won’t restart if any GameObject collides with the enemy.

  // Initiates when something collides with enemy
    void OnTriggerEnter2D(Collider2D collider)

    if (collider.gameObject.CompareTag(“Player”)) {
       {
          SceneManager.LoadScene(SceneManager.getActiveScene().buildIndex);
       }
    }

Add this script into your enemy. It will reset the scene which in theory will bring the player back to start. Remember to call the UnityEngine and UnityEngine.SceneManagement API services at the start. Also, make sure to have the player tag on the player, so the scene won’t restart if any GameObject collides with the enemy.

  // Initiates when something collides with enemy
        void OnTriggerEnter2D(Collider2D collider) {
    
        if (collider.gameObject.CompareTag(“Player”))
           {
              SceneManager.LoadScene(SceneManager.getActiveScene().buildIndex);
           }
        }
added 10 characters in body
Source Link
OKprogrammer
  • 522
  • 1
  • 7
  • 20

Add this script into your enemy. It will reset the scene which in theory will bring the player back to start. Remember to call the UnityEngine and UnityEngine.SceneManagement API services at the start. Also, make sure to have the player tag on the player, so the scene won’t restart if any GameObject collides with the enemy.

  // Initiates when something collides with enemy
    void OnTriggerEnter2D(Collider2D collider)

    if (collider.gameObject.CompareTag(“Player”)) {
       {
          SceneManager.LoadScene(SceneManager.getActiveScene().buildIndex);
       }
    }

Add this script into your enemy. It will reset the scene which in theory will bring the player back to start. Remember to call the UnityEngine and UnityEngine.SceneManagement API services at the start. Also, make sure to have the player tag on the player, so the scene won’t restart if any GameObject collides with the enemy.

  // Initiates when something collides with enemy
    void OnTriggerEnter2D(Collider2D collider)

    if (collider.gameObject.CompareTag(“Player”)) {
    {
          SceneManager.LoadScene(SceneManager.getActiveScene().buildIndex);
    }
}

Add this script into your enemy. It will reset the scene which in theory will bring the player back to start. Remember to call the UnityEngine and UnityEngine.SceneManagement API services at the start. Also, make sure to have the player tag on the player, so the scene won’t restart if any GameObject collides with the enemy.

  // Initiates when something collides with enemy
    void OnTriggerEnter2D(Collider2D collider)

    if (collider.gameObject.CompareTag(“Player”)) {
       {
          SceneManager.LoadScene(SceneManager.getActiveScene().buildIndex);
       }
    }
Source Link
OKprogrammer
  • 522
  • 1
  • 7
  • 20

Add this script into your enemy. It will reset the scene which in theory will bring the player back to start. Remember to call the UnityEngine and UnityEngine.SceneManagement API services at the start. Also, make sure to have the player tag on the player, so the scene won’t restart if any GameObject collides with the enemy.

  // Initiates when something collides with enemy
    void OnTriggerEnter2D(Collider2D collider)

    if (collider.gameObject.CompareTag(“Player”)) {
    {
          SceneManager.LoadScene(SceneManager.getActiveScene().buildIndex);
    }
}