Button.disable = true not working from host to client

Godot Version

4.2.2

Question

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.

func _on_button_select_pressed():
	if is_wizard_selected == true:
		rpc("wizard_is_selected")
		button_wizard.hide()
		button_wizard_disabled.show()
		button_officer.hide()
		button_knight.hide()
		button_officer_disabled.show()
		button_knight_disabled.show()
		button_select.hide()
		button_ready.show()
		change_button_style_on_disable(button_wizard_disabled, Color.CORAL, Color.ORANGE_RED)
		
	if is_officer_selected == true:
		rpc("officer_is_selected")
		button_officer.hide()
		button_officer_disabled.show()
		button_wizard.hide()
		button_knight.hide()
		button_wizard_disabled.show()
		button_knight_disabled.show()
		button_select.hide()
		button_ready.show()
		change_button_style_on_disable(button_officer_disabled, Color.DARK_VIOLET, Color.ROYAL_BLUE)
		
	if is_knight_selected == true:
		rpc("knight_is_selected")
		button_knight.hide()
		button_knight_disabled.show()
		button_wizard.hide()
		button_officer.hide()
		button_wizard_disabled.show()
		button_officer_disabled.show()
		button_select.hide()
		button_ready.show()
		change_button_style_on_disable(button_knight_disabled, Color.CORNSILK, Color.BLUE)
		
@rpc("any_peer", "call_remote", "reliable")	
func wizard_is_selected():
	button_wizard.hide()
	button_wizard_disabled.show()
	change_button_style_on_disable_alternate(button_wizard_disabled, Color.CORAL, Color(.18, .18, .18))

@rpc("any_peer", "call_remote", "reliable")	
func officer_is_selected():
	button_officer.hide()
	button_officer_disabled.show()
	change_button_style_on_disable_alternate(button_officer_disabled, Color.DARK_VIOLET, Color(.18, .18, .18))
		
@rpc("any_peer", "call_remote", "reliable")	
func knight_is_selected():
	button_knight.hide()
	button_knight_disabled.show()
	change_button_style_on_disable_alternate(button_knight_disabled, Color.CORNSILK, Color(.18, .18, .18))

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.