Hi, I’m coding a multiplayer peer to peer 3D game and I’m having the following problem with the mini map management:
When the player is alone the mini map works correctly but then, when a player joins the party, the mini map of the single player follows the player who joined.
I found the solution myself, the player’s position and rotation had to be sent by a signal on the main scene (scene where the player moves, map). example:
Player’s code
signal mini_map_position_changed(position_value)
signal mini_map_rotation_changed(rotate_value)
func _physics_process(delta):
#mini_map
mini_map_position_changed.emit(global_position)
mini_map_rotation_changed.emit(global_rotation)
Map code
func add_player(peer_id):
var player = Player.instantiate()
player.name = str(peer_id)
add_child(player)
if player.is_multiplayer_authority():
player.mini_map_position_changed.connect(update_mini_map_position)
player.mini_map_rotation_changed.connect(update_min_map_rotation)
func _on_multiplayer_spawner_spawned(node):
if node.is_multiplayer_authority():
node.mini_map_position_changed.connect(update_mini_map_position)
node.mini_map_rotation_changed.connect(update_min_map_rotation)
func update_mini_map_position(position_value):
mini_map.position = Vector3( position_value.x, mini_map.position.y, position_value.z)
func update_min_map_rotation(rotate_value):
mini_map.rotation = Vector3( mini_map.rotation.x, rotate_value.y, mini_map.rotation.z)