Hi, I’m working on a Fan made halo game called Project BackBurn. And I’m wondering how I would handle armor customization for the Spartan’s. I have all the armor pieces attached to the under suit that is rigged.
So would I have a button that sets each armor piece active using “Set Active” and the same for disabling armor pieces? But how would that effect it in the actual game? Ughhh I need help.
You need to brake it down into different parts.
First have a script on each Armor Piece parent with some info about it and the ability to change the Armour pieces active status, example below.
public class ArmorPiece : MonoBehaviour
{
public string id;
public GameObject armorPiece;
public bool isActive;
public void ToggleActiveState()
{
isActive = !isActive;
armorPiece.SetActive(isActive);
}
}
And then some sort of Manager for all ArmorPieces, example below.
public class ArmorManager : MonoBehaviour
{
public GameObject[] armorGameObjects;
public Dictionary<string, ArmorPiece> armorPieces;
private void Start()
{
armorPieces = new Dictionary<string, ArmorPiece>();
foreach (GameObject armorGameObject in armorGameObjects)
{
ArmorPiece armorPiece = armorGameObject.GetComponent<ArmorPiece>();
if (armorPiece != null)
{
armorPieces.Add(armorPiece.id, armorPiece);
}
}
}
public void ToggleArmorStatus(string armorID)
{
if (armorPieces.ContainsKey(armorID))
{
armorPieces[armorID].ToggleActiveState();
}
}
}
And then to toggle Armor pieces create buttons with the that onclick point to ToggleArmorStatus
with the id of that buttons Armor Piece as the value.
That is just pseudo code but gives you more than enough to go on, and gives an idea on how to brake things down into the different parts needed to accomplish something a little more complex.