So, in the code below, I have a part of a multiplayer character selection screen, with just one of the characters. The intended functionality is that one of the players selects a character, and that character and all other possible selections is disabled. for that player. But on other players, only the one selection the first player made is disabled.
The problem is that when the host makes a selection, it disables all of the hosts buttons AND all of the clients buttons (instead of just the hosts selection)
Even stranger is that when I tested it, this code setup worked when I used a .hide() instead of .disabled = true. Any idea’s as to why this could be occurring? Is it a problem unique to the disabled property for buttons going out over the network somehow?
func _on_button_select_pressed():
var peer_id: int = multiplayer.get_unique_id()
if is_wizard_selected == true:
rpc("wizard_is_selected", peer_id)
button_select.hide()
button_ready.show()
@rpc("authority", "call_local", "reliable")
func wizard_is_selected(peer_id):
if peer_id == multiplayer.get_unique_id():
button_wizard.disabled = true
button_officer.disabled = true
button_knight.disabled = true
print("character select peer id: ", peer_id, "multiplayer authority: ", is_multiplayer_authority())
elif peer_id != multiplayer.get_unique_id():
print("character select server status 2", multiplayer.is_server)
button_wizard.disabled = true
change_button_style_on_disable(button_wizard, Color.CORAL, Color.ORANGE_RED)
So, I didn’t come up with a direct solution, but the workaround I came up with was to make a second set of buttons that are hidden and disabled from the editor by default. Then when the client or host makes a selection, I unhide the relevant disabled version of that button, and hide the version that the player initially clicked on. It’s clunky to write, but this system ended up working perfectly while trying to use the button disable through code did not work at all, so I think there is actually a bug using .disable or .set_disable(true) in at least a network context.