I’m trying to work something with the polygon assets I have, there are a number of gameobjects that are under the prefab that I want to set on and off base on the armor config equipped by their name. I have an enum on the armor config and a component that takes in the transformation that has the game objects.
Armor config
[SerializeField] Armor equippedPrefab = null;
[SerializeField] GearMade gearMade = GearMade.SetBase;
[SerializeField]
Modifier[] additiveModifiers;
[SerializeField]
Modifier[] percentageModifiers;
const string armorName = "Armor";
[System.Serializable]
struct Modifier
{
public Stat stat;
public float value;
}
the BodyStuff script
[SerializeField] Transform hipGear = null;
private void AttachArmor()
{
foreach (GameObject child in hipGear)
{
if (currentArmorConfig.GetGear() == GearMade.SetBase)
{
child.Find("SetBase").SetActive(true);
}
}
}
I stopped here, getting an error on (child.Find), I still don’t know how to fully use foreach or if it’s not to be used that way. I would use the same method for the weapon prefab from the course, but the gameoject in this asset has a root transform built-in, so spawning it causes it to not work. I’ve tested turning the object on and off from the inspector and the asset still works fine, now I’m just trying to do so from the script base on the armor config’s enum.