Possible to change transform arrays into a smaller number?

I currently have a state machine AI system at hand, that does the basic patrol, alert, and chase functions.
is it possible to resize a transform array during runtime when another object is set inactive

I don’t understand how a state machine has anything to do with your array of transforms. Is it the array of AI transforms?
In general if you intend to resize a list of stuff, a list is easier to handle. Resizing an array by simply removing from the end of the array be done like this

//at the top of your script
using System

//in usage, lets say the originalArray length is 10
int newLength = 2;
Array.Resize(ref originalArray, newLength);

but removing anything in between would require you to create a new array and load in the elements you want, and assign the new array to your variable, which is troublesome and IMO bad practice any way.

Using a list:

// at the top of your script
using System.Collections.Generic;

//in usage
List<Transform> aiList = new List<Transform>();
//to add element
aiList.Add(*element as a transform*);
//removing element
aiList.Remove(*element as a transform*)
//or removing if you knwo the index
aiList.RemoveAt(*int representing index in list*);
1 Like