I'm trying to make an options screen that's maneuverable by pressing the arrow keys (or by the directional pad on a controller).
I have tried putting in code to allow for this form of navigation. When the user presses down a few times, the "Credits" option is the only thing highlighted, even though the player should be able to control which option is highlighted. I don't know why it won't highlight another option when the player presses up or down.
The following is the code for the options screen:
# Which option is selected?
var option_number: int = 0
var shadow_color: String = "2dea12"
# Nodes to reference
onready var x_sensitivity: Label = $"VBoxContainer/HBoxContainer/X-sensitivity"
onready var y_sensitivity: Label = $"VBoxContainer/HBoxContainer2/Y-sensitivity"
onready var test_play: Label = $VBoxContainer/Test_play
onready var credits: Label = $VBoxContainer/Credits
# Collect all the options into an array for handy reference.
var list_of_options: Array = 
list_of_options = [
x_sensitivity, y_sensitivity, test_play, credits
# Depending upon whether the player presses up or down on the directional pad, increment or decrement the "option_number" variable.
option_number = clamp( option_number + 1.0, 0.0, list_of_options.size() - 1 )
option_number = clamp( option_number - 1.0, 0.0, list_of_options.size() - 1 )
if option_number > list_of_options.size() - 1:
elif option_number < 0:
for option in [0,1,2,3]:
if option == option_number:
# Make the option letters look highlighted.
list_of_options[option_number].add_color_override( "font_color_shadow", Color(shadow_color) )
# Make the option letters look plain.
list_of_options[option_number].add_color_override("font_color_shadow", ColorN("black") )