I have an array with 8 positions, i want to set a node to 1 of them then remove that position from the array. How would i remove it?

Godot Version

4.3

Question

So i have 8 sprites, i want them to randomly select a position from an array then glide over to that position but i want each one to have its own position. I want to remove the positions that have already been used from the array but dont know how.

var random_index = randi_range(0, positions.size()) # get a random index
var random_position = positions.pop_at(random_index) # get and remove the position at index
1 Like

this worked well but i had to add - 1 to positions.size() otherwise it broke
Thank you so much

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.