I created GameObject and instantiated then destroyed. I gave that Powerups () function in Update. So, After the destruction of the GameObject the IF condition is checking still what could i do to solve this to call that Game Object whenever needed
Note: I didn’t use physics and all.
void Powerups()
{
CreatePowerUp();
if((transform.position.x + (widthPlayer/2)) >= (Powup.transform.position.x))
{
Debug.Log("Objct");
Destroy(Powup);
}
}
void CreatePowerUp()
{
if(!val1)
{
Powup = Instantiate(Powerup) as GameObject;
val1 =true;
}
}