Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | KuroDev |
I am trying to get my menu to assign a controller to one player if they press the start button. The functionality works if I press start on controller 0 first. If I press start on controller 1 first, it assigns it to both players. How do I fix this?
func _input(event):
if not P1Set and not P2Set:
if event is InputEventJoypadButton and event.button_index == JOY_START:
P1Set = true
P1InputType = InputEventJoypadButton
P1InputDevice == event.device
$Panel/Player1Join.visible = false
$Panel/Player1CharacterName.visible = true
print("Player 1 is Ready to Start. Using device:", event.device)
elif event is InputEventKey and event.scancode == KEY_ENTER:
P1Set = true
P1InputType = InputEventKey
$Panel/Player1Join.visible = false
$Panel/Player1CharacterName.visible = true
print("Player 1 is Ready to Start. Using device:", event.device)
if P1Set and not P2Set:
if event is InputEventJoypadButton and event.button_index == JOY_START and event.device != P1InputDevice:
P2Set = true
P2InputType = InputEventJoypadButton
P2InputDevice == event.device
$Panel/Player2Join.visible = false
$Panel/Player2CharacterName.visible = true
print("Player 2 is Ready to Start. Using device:", event.device)
elif event is InputEventKey and event.scancode == KEY_ENTER and P1InputType == InputEventJoypadButton:
P2Set = true
P2InputType = InputEventKey
$Panel/Player2Join.visible = false
$Panel/Player2CharacterName.visible = true
print("Player 2 is Ready to Start. Using device:", event.device)
if P1Set and P2Set:
print("Both Players are Ready to Start!")
if event is InputEventKey:
if event.scancode == KEY_ESCAPE:
get_tree().quit()
if event is InputEventJoypadButton:
if event.button_index == JOY_SELECT:
get_tree().quit()