Topic was automatically imported from the old Question2Answer platform.
Asked By
pit
Here’s my current code. it doesn’t crash but in-game whe mouse wheel does nothing
if Input.is_action_just_pressed("jump") or Input.is_mouse_button_pressed(BUTTON_WHEEL_UP) and is_on_floor():
snap_vector = Vector3.ZERO
gravity_local = Vector3.UP * JUMP_FORCE
The easiest way is to go into your input mapping and create an input with mouse wheel up (I will for reference call it foobar in my code below) and then add this line
Input.is_action_just_released("foobar")
so your line would be:
if Input.is_action_just_pressed("jump") or Input.is_action_just_released("foobar") and is_on_floor():
This worked wonders but a question still remains. Why can’t I just add MOUSE_WHEEL_UP as an alternative input for “jump” alongside the space bar. It was the first thing I tried and it seemed to be the most intuitive but it doesn’t work like that for some reason.
pit | 2022-12-01 23:47
There is no “pressed” on a mouse wheel up so if you are using is_action_just_pressed to call it then it will never be seen as having been pressed. A mouse wheel action can only be located by checking if the action was just performed (or just released as noted in godot) so you cannot just call the same input action on jump and expect to detect a mouse wheel movement.