Sorry, the released thing was a copy paste error. I don't know why it doesn't work on process, but I just tested it and this definitely works.

func _input(event):
	if event.is_action_pressed("scroll_up"):
		print("scroll_up")
	if event.is_action_pressed("scroll_down"):
		print("scroll_down")
  • DJM replied to this.

    cybereality ok that works.tnx
    but i dont understand why my code doesn't.
    could it be cause it is in a sub function of physics process?

    i want to use it to iterate between icons in a HBoxContainer.

    how do i get all the icons in the container?
    what i want to do is > if mousescrollup or mousescrolldown> open inventory(basicly unhide the hboxcontainer> hide the current weapon> use mouse scroll up or down to iterate between icons> press "fire" to select weapon and close inventory.

    Could be a timing issue. _input() happens as soon as any input is done, while _physics_process() happens at a fixed rate (60Hz by default). Input can happen at much higher rates. I think the default on Windows is 125Hz, but some mice are much higher (mine is 1000Hz).

    • DJM replied to this.

      You can get the container node, then use get_children() to get all the children. Or iterate and use the index numbers. Then you select or hide based on the index (this can be based on the weapon_index the mouse wheel controls).

      for icon in icon_container.get_children():
          print(icon.name, " at index: ", icon.get_index())
      • DJM replied to this.

        how do i add a delay to the selection, cause mouse scrollwheel input is very fast
        i dont want to use a timer.

        in unity i did things like this>

        if (Time.time > nextselect):
        nextselect = Time.time + 1.0
        for icon in weaponInventory.get_children():
        			print(icon.name, " at index: ", icon.get_index())

        however , i check if inventory is open (and call open_inventory)and do the code there. so there is no 'delta' variable i can use

        func open_Inventory():
        	weaponInventory.visible = true
        	for icon in weaponInventory.get_children():
        			print(icon.name, " at index: ", icon.get_index())

        You would use:

        var now = OS.get_unix_time()

        That returns a millisecond value.

        var now = OS.get_unix_time()
        if (now > nextselect):
            nextselect = now + 1000
        • DJM replied to this.

          Sorry, that was Godot 3.x code. This will work on 4.0.

          var now = Time.get_unix_time_from_system()
          if (now > nextselect):
              nextselect = now + 1.0
          • DJM replied to this.