- Home /
Reset Lives Object
I am making a game and the player's lives are displayed as game objects, i did this as i wanted to make them spin in the corner of the game while it plays. at the moment my script says that when you lose a life, delete one of the objects, once you lose all your lives it goes to a game over screen and you can press either a play again or a quit button. This is the script for it:
using UnityEngine;
using UnityEngine.SceneManagement;
public class Button : MonoBehaviour
{
public void NextScene()
{
SceneManager.LoadScene("GameScene");
}
public void QuitGame()
{
Application.Quit();
}
}
how do i make it that once the scene loads all the objects that were deleted come back? at the moment it just restarts with the player having 0 health as the objects are all deleted. i am using this to detect when the last health object is gone:
if(PlayerLives.gameOverP1W)
{
SceneManager.LoadScene("GameOverP1W");
}
and in a different script:
if (playerOneRound3)
{
Destroy(playerTwoLifeThreeObj);
gameOverP1W = true;
}
The game has two players that fight each other, and the life objects are the playerTwoLifeThreeObj etc.. the gameOverP1W and etc.. are public static bools too
Your answer
![](https://koobas.hobune.stream/wayback/20220613000136im_/https://answers.unity.com/themes/thub/images/avi.jpg)