i would like to code something like this
void Update ()
{
if ((player.transform.position.z-other.transform.position.z) > 27 )
{
Destroy(other,0.5f);
}
if ((player.transform.position.z-other1.transform.position.z) > 27)
{
Destroy(other1,0.5f);
}
if ((player.transform.position.z-other2.transform.position.z) > 27)
{
Destroy(other2,0.5f);
}
if ((player.transform.position.z-other3.transform.position.z) > 27)
{
Destroy(other3,0.5f);
}
if ((player.transform.position.z-other4.transform.position.z) > 27)
{
Destroy(other4,0.5f);
}
if ((player.transform.position.z-other5.transform.position.z) > 27)
{
Destroy(other5,0.5f);
}
}
which the diffences of the distances in z axis will result in destroy of the other game object. the player will always moves front so i need it to update everytime.
the problem i facing now is the loop only execute the 1st 1, is it possible for me to proceed to next if loop?
or should i use others method like switch?
guild and tips is needed by u all =) thanks