Here is the code:
func next_weapon() -> void:
var index = get_current_index()
index = wrapi(index + 1, 0, get_child_count())
equip(get_child(index))
func previous_weapon() -> void:
var index = get_current_index()
index = wrapi(index - 1, 0, get_child_count())
equip(get_child(index))
However, scrolling down does not wrap around to change weapons. It does change once, but does not continue changing as the scroll wheel scrolls down. I’m thinking this is because get_child_count()
returns a value of 2 and so when the index returns 0 and subtracts 1, it returns 2 which is not assigned to any value in the array (although… shouldn’t it still continue subtracting on each scroll? idk). Are others experiencing this?