Cycle through Object array. First in first out logic.

i have a character that throws spears. He can stick them to walls and jump on them. i

I want the player to have no more than 6 spears stuck in the wall at once. when the 7th spear is stuck, it should destroy the oldest existing spear. i believe using object arrays is the answer to my problem. my print strings show my current spear count going up. but once it comes time to spawn spear 7 and destroy spear 1 nothing happens. i can just keep throwing and counting.

heres the code.

You can’t iterate over an array and modify it. Since you’re always removing the first element if it has 7 items, you don’t need the for loop. The is valid node and the branch node that follow it can also be removed.