is that indentation intentional?
mouse wheel input doesnt get detected
- Edited
You might want to put that in _input():
func _input(event):
if event.is_action_pressed("mouseUP"):
weapon_change_number += 1
if event.is_action_pressed("mouseDOWN"):
weapon_change_number -= 1
Megalomaniak no not intentional, dont know how to correctly post code on the new forum,
cybereality what 's the difference if i put it in input? also why do i need to call 'action released' for mouseDOWN?
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")
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).
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())
- Edited
cybereality yeah i use a gaming mouse to work so thats probably why.
cybereality ill try it . tnx
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
cybereality error >
"get_unix_time()" not found in base "OS"
im on linux godot 4alpha
- Edited
DJM im on linux godot 4alpha
Try Time.get_ticks_msec()
https://docs.godotengine.org/en/latest/classes/class_time.html#class-time-method-get-ticks-msec
(But note that in 500 million years, it may cause a bug.)
- Edited
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
cybereality tnx! works fine