So i got a script that makes the player spawn and have lives everytime the player is destroyed by the enemy. The problem is the player will spawn in the beginning, but when an enemy destroys the player, the player gameobject does not respawn. Here is the script for reference, if you can help to fix this issue thank you. I don't know why the player does not respawn back after the enemy destroys the game object.
public Transform playerShip;
public int playerLives = 2;
public GameObject player;
void Start ()
{
if (player == null && playerLives >= 1) {
playerLives--;
Instantiate (playerShip, new Vector3 (0, 0, 0), Quaternion.Euler (0, 0, 180));
player = GameObject.FindGameObjectWithTag ("Player");
}
}
↧