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.
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.
First, you do not need to count the number of added items; it is easier to obtain the length of the array instead. Second, removing an item from the array does not imply that the object will also be removed. You need to destroy the actor separately before removing it from the array.