Kill Oldest Object

lets say your character can shoot 5 fireballs at a time. you could have an int called PoolIndex, which defaults to zero, and another int called maxPoolSize, which is set equal to 5 for this example.

the first 5 shots are done normally, spawning and filling up the list. the 6th shot realizes the array length is equal or greater than maxPoolSize, so it branches to a separate method.

that method would take the element at index PoolIndex, reset its state to default, move it to the spawn point, and give it the proper InitialVelocity, then it would increment PoolIndex, and check if PoolIndex is greater than MaxPoolSize, and if so, it subtracts MaxPoolSize from PoolIndex, and sets that as PoolIndex.

now, if those fireballs hit something or go beyond a certain range, they should change their state to inactive, instead of destroying themselves. the inactive state can set the objects visibility to hidden and zero out its position and velocity.

since the inactive elements are not destroyed or removed from the list, the list elements never have to change their index, and you never have to loop through each element asking it for a TimeStamp variable, and you never have to loop through to find which elements are inactive.

there are other, more complicated ways to implement an object pool, but if you want to overwrite the oldest element with the newest, you can use this simple method.