In a multiplayer game, how do you determine which player performs a click on a tilemap?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AtlantisXY

Hi! I’m trying to handle point-and-click movement in a multiplayer game. There will only be 2 players in a game, each controlling 3 characters. Is it possible to get the network id of the user who clicks on the tilemap? Based on the network id, I plan on fetching the node by name (which is their own network id), then get the appropriate child character node in order to send the movement instructions to it.

Sample runtime node tree:

	gamestate (Node)
	main menu (Control)
	world (Node2D)
		players (Node)
			1294647007 (Node2D)
				character_1 (Sprite)
				character_2 (Sprite)
				character_3 (Sprite)
			1487964002 (Node2D)
				character_4 (Sprite)
				character_5 (Sprite)
				character_6 (Sprite)
		map (Tilemap)

Tilemap script:

extends TileMap
func _input(event):
	if event is InputEventMouseButton and event.is_pressed():
		if event.button_index == BUTTON_LEFT:
			##click detected on tilemap, but from whom??
			##handle movement here?

Thank you so much in advance for your help!

Why not make the user who clicks the tilemap a remote call and let other players know?

Vignesh S | 2020-04-20 21:07