An error with meshinstace map when i add networking to the game

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

I build a multiplayer game. I have 3 scene:Lobby,Game,Player.When a client connect to server, the game start and I use function add_child() to add player node to game scene.
At normal, when I run the project, the meshinstace map in game scene will stay still and don’t move when the player move. But when I add network to the game, when i run the project, the meshinstace map move with the player.Can anybody help me to fix it?
That is my game.tscn script:
extends Node
onready var map=$MeshInstance
func _ready():
net.set_ids()
create_players()

func create_players():
for id in net.peer_id:
create_player(id)
create_player(net.id)
func create_player(id):
var p =preload(“res://Player.tscn”).instance()
add_child(p)
p.initialize(id)

This is the lobby script:
extends Control

func _ready():
get_tree().connect(“connected_to_server”,self,“connected”)
func connected():
if not net.is_host:
rpc(“begin_game”)
begin_game()
remote func begin_game():
get_tree().change_scene(“res://Game.tscn”)

This is network script
extends Node

const port=31400
const max_player=100
const ip=“127.0.0.1”
const offline=false
var id =null
var is_host=false
var peer_id=
func start_server():
is_host=true
var peer = NetworkedMultiplayerENet.new()
peer.create_server(port,max_player)
get_tree().network_peer=peer
func join_server(server_ip):
if offline:
server_ip=ip
var peer=NetworkedMultiplayerENet.new()
peer.create_client(ip,port)
get_tree().network_peer=peer
func set_ids():
id=get_tree().get_network_unique_id()
peer_id=get_tree().get_network_connected_peers()
This is player script:
extends KinematicBody

const speed=10
var is_master=false
var velocity=Vector3()
var accel=5
var mouse_sensitivity=0.5
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func _process(delta):
if Input.is_action_pressed(“ui_cancel”):
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
func initialize(id):
name=str(id)
if id==net.id:
is_master=true
else:
$MeshInstance.get_surface_material(0).albedo_color=Color8(255,0,0,255)
func _input(event):
if event is InputEventMouseMotion:
rotate_y(deg2rad(-event.relative.xmouse_sensitivity))
$MeshInstance.rotate_x(deg2rad(-event.relative.y
mouse_sensitivity))
$MeshInstance.rotation.x = clamp($MeshInstance.rotation.x, -0.8, 0.8)
func _physics_process(delta):
if is_master:
var dir=Vector3()
var head_basis=$MeshInstance.get_global_transform().basis
if Input.is_action_pressed(“front”):
dir+=head_basis.z
if Input.is_action_pressed(“back”):
dir-=head_basis.z
if Input.is_action_pressed(“left”):
dir-=head_basis.x
if Input.is_action_pressed(“right”):
dir+=head_basis.x
dir=dir.normalized()
velocity=velocity.linear_interpolate(dirspeed,acceldelta)
move_and_slide(velocity)
rpc_unreliable(“update_translation”,translation)
remote func update_translation(trans):
translation=trans