Hi,
I’m a little confused as to how this works.
foreach(Transform weapon in transform)
{
if(weaponIndex == currentWeapon)
{
weapon.gameObject.SetActive(true);
}
else
{
weapon.gameObject.SetActive(false);
}
weaponIndex++;
}
I’ve got it working. I just don’t understand how!
it is iterating through the parent’s transform - that’s clear enough. But how does the parent’s transform know that there are children, each with their own transforms, and these ‘belong’ to the parent’s own transform?
I’m just a bit confused how the parent transform seems to be ‘storing’ the transforms for the children, too.
Thanks!