Question by
Trash_C4t · Aug 05, 2020 at 11:15 AM ·
gameobjectincrementassignment
Trying to disable gameobjects depending on what number an int is, How would I go about doing this?
I have 13 images under a transform, and they are named "Bullet1", "Bullet2", "Bullet3" and so on. I want to be able to edit them depending on how much ammo I have left, by changing their Opacity or just disabling them. I have no clue why it's not working.
Snippet from the script:
for (int i = (int)bulletsLeft; i <= maxClip + 1; i++)
{
i += 1;
currentBullet = GameObject.Find("9mmBullets").transform.Find("Bullet" + i.ToString()).gameObject;
if (i < ammo)
{
currentBullet.SetActive(false);
}
else if (i >= ammo)
{
currentBullet.SetActive(true);
}
}
It's under the Update function so it will update every frame. Any Ideas?
Comment