#Help with item switching visibility

1 messages · Page 1 of 1 (latest)

trail lodge
#

I have a weapon switcher code that basically switches weapons only in the Output Text menu. All items models are visible, and I want all to be invisible except the selected one,
My understanding, what I need to do is make the Array visibility = false, but make the Selected Variable visibility = True

Code looks like,

Var weapons: Array[Node] = []
Var selected: = 0

Func _ready() -> void:
print(weapons[selected])

Func _process(delta):
just some code to swap the selected button number on a button press, and to return the array to the beginning when you reach the end

gloomy nimbusBOT
visual ivy
#

what's the problem?

My understanding, what I need to do is make the Array visibility = false, but make the Selected Variable visibility = True
Yeah, that sounds close to right. To be even more pedantic: "Iterate over each node in the array, which you need to have previously initialized somehow. If it's the selected index, mark the node as visible; otherwise, not visible."

  1. Where are you initializing it? How often does its membership change, and how are you keeping it in sync when that happens? (maybe best to say "it never changes"!)
  2. When does selected change? How are you keeping that in sync?
  3. Code formatting! Read and follow the robot's advice:
tardy apexBOT
#
Embedding code in discord messages
Inline Code

When you surround some words with single backticks like `this`, it will be formatted as code.

Code Blocks

You can also include code blocks by surrounding the code with three backticks. If you add "swift" then you will also get basic syntax highlighting:
```swift
print("hello world")
```
Discord will then show it as a code block like this:

print("hello world")
Upload

If your code snippet is rather long, you can upload it to a text paste site. One option that supports syntax highlighting for GDScript is https://bpa.st/

trail lodge
# visual ivy what's the problem? > My understanding, what I need to do is make the Array vis...

Thank you! And sorry I just got to this now. Every item is a child node of a Hand node, but . The array is initialized with a button press, it only switches weapons with a button press. There is always a item out, there is no free hand. To my knowledge you cannot set a boolean on a node array. The Selected node works,

I’m guess I’m asking is there way to set a Boolean on a node array

trail lodge
#

I just fixed my problem in a stupid way lol