Custom Array Calculation Problem

So, there is no easy way to explain this but there are certain ways in which I have done things for the creation of this game to keep everything corresponding directly to one another. I am coming across a problem whereby GameObject.FindObjectswithTag will sort my object array into an order which I must reference two objects into an index for another array. However, my indexing is all out because I cannot find a way of referencing two objects in an array which are next to each-other whilst being in an incrementing statement. I don’t feel confident explaining this but I hope from my code you can see what I’m trying to do:

public void ClassSelection(GameObject classSelected)
{
    // ClassButtons.Length = 6
	for (int i = 0; i < ClassButtons.Length; i++)
	{

		if (classSelected == ClassButtons*)*
  •   	{*
    

// CharacterArmouryScript.ArmourTypes.Length = 3

  •   		for (int t = 0; t < CharacterArmouryScript.ArmourTypes.Length; t++)*
    
  •   		{*
    
  •   			if (i == t || i == (ClassButtons.Length - (t + 1)))*
    
  •   			{*
    
  •   				CharacterArmouryScript.ArmourTypeReference = t;*
    
  •   			}*
    
  •   			// Current 2 by 3 Array Type:*
    
  •   			// 0 = [0] or [5]*
    
  •   			// 1 = [1] or [4]*
    
  •   			// 2 = [2] or [3]*
    
  •   			// What I need: Ideal Algorithm Array Values*
    
  •   			// 0 = [0] or [1]*
    
  •   			// 1 = [2] or [3]*
    
  •   			// 2 = [4] or [5]*
    
  •   		}*
    

I will answer as many comments as possible if i havnt explained myself enough, but Basically what i need is SolutionX:
if ( i == t || i == SolutionX )
// What I need: Ideal Algorithm Array Values
// i = [0] or [1]
// i = [2] or [3]
// i = [4] or [5]
This would be such a huge help if anyone could help me, I feel its more of a maths issue; or im just being even more silly about what i’m doing. Thanks :slight_smile:

The best solution is to avoid using GameObject.FindObjectswithTag at all.

Either have one script that keeps an array (or list) of your objects which you populate in the inspector.

Or have each of the objects register themselves into a static list in Awake and remove in OnDestroy (or in OnEnable and OnDisable). I use this approach for most situations.