How to use the MOUSEWHEEL as a Input event

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Godot_Starter

I want to use the mousewheel as a Input event.

For example: Lets say I have a variable var weapon = 5 and I want to use the mousewheel to change the weapon. So if I scroll up I want to increase the number and when I scroll down I want to decrease the number.

What is the simplest way to do this?

Thanks for answers!

:bust_in_silhouette: Reply From: whiteshampoo
var weapon : int = 0

func _input(event : InputEvent) -> void:
	if event is InputEventMouseButton:
		event as InputEventMouseButton
		if event.pressed:
			match event.button_index:
					weapon += 1
					weapon -= 1
			print(weapon) # delete this, if it works

i think it’s self-explanatory. If not, feel free to ask.