- Home /
PowerUp mechanics doesn't works
Hello community.
I've a problem on the state to switch on and off the script components when a int variable comes true.
For example:
void Start()
{
DisparoFase1Jugador = GameObject.FindWithTag("DisparoFase1Jugador");
}
public void PowerUpState()
{
if (powerUp == 1)
{
DisparoFase1Jugador.GetComponent<ArmaScriptJugador1Fase2>().enabled = false;
}
}
I've done a debug.log and it's catching the value 1.
On Hierarchy it's like this:
Jugador_1 = As a parent. Tag is = Player.
Disparo1 = As a child of Jugador_1. Tag is = DisparoFase1Jugador.
Disparo2 = As a child of Jugador_1. Tag is = DisparoFase2Jugador.
Some idea guys? Thanks for the help.
Regards.
This question is a little bit hard to answer as the question is not as clear as it could be.
When you used Debug.Log, did you put it inside the if (powerUp == 1) check? In other words, have you checked that the 'enabled = false' line is reached?
Hi, a bit more information would be nice. Like when is PowerUpState called?
Your question has help me Eleigh. It was not functional at last because I didn't called on the condition. Now I'm calling inside here and by the momento it Works.
void OnTriggerEnter2D(Collider2D colisionador) {
//Colisionador con trigger PowerUp
if (colisionador.gameObject.tag == "PowerUp")
{
PowerUpIncrement();
Debug.Log(powerUp);
PowerUpState();
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Organize the hierarchy a bit more? 1 Answer
Cannot disable a script from another script 2 Answers
How do I make it so that I can attack more than 1 enemy? 1 Answer