Hey! I'm very new to godot and coding. I'm trying to make a crafting menu in which players can click the arrows to switch between the pot and mortar and pestle (I'm planning on adding more objects later) How exactly should I go about this? Any advice is appreciated I'm still learning as I go. Thanks, sorry if this is an obvious question!


You could use an array that contains your objects and define a variable that keeps track of the current index.
Pressing left reduces the index, right increases it.

Pseudo code, using sprites as item for this example:

var item_index
var items : Array
var item_sprite : Sprite2D

func on_index_changed():
      item_sprite = items[item_index]
      # or if you don't replace anything, you could loop over all items in your array, disable/hide them and then only activate the one from the current index. There are different ways to do it.
     
# connect to your button
func increase_index():
      item_index += 1
      on_index_changed()

# connect to your button
func decrease_index():
      item_index -= 1
      on_index_changed()

Thank you! Been stuck on this for a while. Gonna try this out huge thanks

    JessH For what it's worth, from the graphic side if you're doing this on one screen, you can just use the Focus tab to determine which button is focused on. But @trizZzle 's method is best for logic.

      JessH it should be a tab in the inspector for button objects. If you have multiple button instances, you should be able to just put the focus where you want whenever an arrow key is pressed.