0
My player has shield that is disabled in it, and I have a game manager wants to take care for when you can activate the shield or do not put when I instate the player in the scene the game manager does not find the component of the shield, this is because it is disabled, If active he finds more when the time of the shield is over he returns to not find anyone else knows what can be ? I’m using:
void Awake()
{
if (_escudo != null)
{
_escudo = GameObject.Find("Escudo"); //ele acha porque estou iniciando com o escudo ativado
}
else
{
InvokeRepeating("checkComponentes", 0f, 2f);
}
}
here the routine function:
if (_component.input != 0 && _time >= _tempoDuracaoPoderes && _timeDelay <= 0)
{// recebe o aperto do botao e verifica outras condições antes de ativar
StartCoroutine(EscudoForca()); // responsavel por controlar o tempo do escudo
_buttonescudoForca.enabled = false;
_time = 0;
}
else
{
_time += Time.deltaTime;
_timeDelay -= Time.deltaTime;
}
}
IEnumerator EscudoForca()
{
_escudo.SetActive(true); //escudo ativo
_uiEscudo.SetActive(true);// efeito de lente ativa
statusBar.fillAmount = 1;
anim.SetBool("ativado", true);
_timeDelay = 5.0f;
// _escudo = GameObject.Find("Escudo");
yield return new WaitForSeconds(_tempoDuracaoPoderes);
// _escudo = GameObject.Find("Escudo");
_escudo.SetActive(false);
_uiEscudo.SetActive(false);
statusBar.fillAmount = 0;
anim.SetBool("ativado", false);
}
The issue is I can get Gameobject disabled to be able to activate later, as I already do more if the PLAYER is on the screen if instantiated does not work. Thanks in advance...