I still having an issue with < .length >
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameSesion : MonoBehaviour
{
[SerializeField] int playerLives = 3 ;
void Awake()
{
int numGameSessions = FindObjectOfType<GameSesion>().Length;
if (numGameSessions > 1)
{
Destroy(gameObject);
}
else
{
DontDestroyOnLoad(gameObject);
}
}
public void ProcessPlayerDeath()
{
if(playerLives > 1)
{
TakeLife();
}
else
{
ResetGameSesion();
}
}
void TakeLife()
{
playerLives = playerLives -1 ;
int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
SceneManager.LoadScene(currentSceneIndex);
}
void ResetGameSesion()
{
SceneManager.LoadScene(0);
Destroy(gameObject);
}
}