Topic was automatically imported from the old Question2Answer platform.
Asked By
TheJollyReaper
In my two player project, I want to have two separate upgrade screens, one for each player. The menus are up at the same time, and a player should only be able to interact with their own respective menu. I’m having a lot of difficulties making it happen since only one item can be in focus at a time (at least that I’m aware of).
extends Control
func _input(event):
if event is InputEventKey and event.pressed:
match event.scancode:
KEY_A:
$ButtonA.emit_signal("pressed")
KEY_B:
$ButtonB.emit_signal("pressed")
func _on_ButtonA_pressed() -> void:
print("A")
func _on_ButtonB_pressed() -> void:
print("B")
When you now run the game, you can press the A-key to activate ButtonA and print “A”, the B-key to activate ButtonB and print “B” or both at the same time.
I hadn’t thought about assigning each button it’s own key, I was focused (hah) on finding some way on being able to switch which button is being selected with a d-pad/joystick.
This works though! Might have to assign a key to toggle multiple menu screens, or to toggle which set of buttons is accepting requests at a time.