0 votes

Hello, i want to setup a simple weapon manager where selection is done by scrolling the mouse wheel.

What is the most efficient way to achieve this?

Let's say, If i have a variety of weapons as children of the weapon manager, should I them reference as an array to use in a for loop? how do i then name each array's element/indices & match to it's children's indices so i could later use both of them as one indices to change their values from the mouse wheel? Which in return will change the weapon..(Correct if I'm wrong but that's what I understood on get_children from the Node doc):

For example(script is attached to the manager):
var weapons = self.getchildren()
var weapon
index = 0

for weapon in weapons:
if weaponindex:
weapons = self.get
child_count()

am I in the direction? If so how do i continue on from this? thinking about it now, naming each slot will force me to get all the array's & children indices one by one, am I correct? Is there a better & simpler way to achieve this ? Thanks in advance for your helping!

Godot version 3.4
in Engine by (12 points)
edited by

Please log in or register to answer this question.

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 Frequently asked questions and 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 [email protected] with your username.