Hello everyone. I get this very lame problem when dying in the third scene. I don’t get why this is happening. in this scene there is a sceneloader script attached to the gameobject and I also checked the code if the session script instantiate a sceneloader for that purpose.
here is my code for that:
int gameSessionNum;
static int actualPlayerLives;
static int playerScore = 0;
SceneLoader sceneLoader;
void Awake()
{
gameSessionNum = FindObjectsOfType<GameSession>().Length;
if (gameSessionNum > 1)
{
Destroy(gameObject);
}
else
{
DontDestroyOnLoad(gameObject);
}
}
void Start()
{
sceneLoader = FindObjectOfType<SceneLoader>();
actualPlayerLives = playerMaxLives;
}
public void ProcessPlayerDeath()
{
if (actualPlayerLives <= 0)
{
actualPlayerLives = playerMaxLives;
sceneLoader.LoadStartScene();
}
else
{
actualPlayerLives--;
sceneLoader.ReloadScene();
}
}
Thanks for helping me