My player has a shield that is disabled in it, and I have a game manager that wants to take care when it can activate the shield or not when the player is instantiated in the scene the game manager does not find the component of the shield, this is because he is disabled, if active he finds more when he finishes the time of the shield he returns to not finding anybody else knows what it 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's 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 question is do I get the GameObject disabled to be able to activate later, just like I already do this more if the PLAYER is on the screen if instantiated does not work. Thanks in advance ...