0 votes

I'm a completely noob to the whole gamedev thing (only been at it a couple days) but so far I have a character with platformer movement, a handful of tilesets, enemies that move toward the player, coins that increase your score, and 2 different weapons. One of them is a full-auto machine gun, and the other is a rocket launcher that is slow but does powerful AoE damage. My goal is to eventually have something like 5 or 6 weapons total, so what I want to do is have a list of weapon sprites always at the bottom of the screen, and by using the scroll wheel you can visually cycle through them to change a variable in the Player script that controls what gun you have equipped. I haven't found many tutorials on the UI system, so a pointer in the right direction would be greatly appreciated as I've been stumped on this one for a little bit! :(
Thanks in advance! :)

in Engine by (67 points)

1 Answer

0 votes

Here's a way to check if the scroll wheel is being used, but I stole it from someone else who was trying to do zooming in and out. Anyways, full credit to Dodolta for finding this input:

if event is InputEventMouseButton:
     if event.is_pressed():
         if event.button_index == BUTTON_WHEEL_UP:
             item_equipped += 1
         if event.button_index == BUTTON_WHEEL_DOWN:
             item_equipped -= 1
by (114 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.