Why does not the kinematicbody2d move neither in my side nor on the other players side when trying to use RPC?

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

I am trying to make a multiplayer game and my player doesn’t move when I am using unreliable rpc

When I try to move the player doesn’t move but the engine doesn’t show any kind of errors as well.

I am using a auto-loaded script : Network, to create the players
And, a player script to control and send rpc(s) to the other side

Here is the Network script code:

extends Node

    var PORT : int = 35000
    var MAX_CLIENTS : int = 4
    var my_id : int = 1
    var IP_ADDRESS : String = ""
    var peer_ids : Array
    func _ready():
    	get_tree().connect("connected_to_server", self, "connected")
    	get_tree().connect("server_disconnected", self, "disconnected")
    #	get_tree().connect("connection_failed", self, "connection_falied")
    	get_tree().connect("network_peer_connected", self, "peer_connected")
    	get_tree().connect("network_peer_disconnected", self, "peer_disconnected")
    func create_server():
    	var peer = NetworkedMultiplayerENet.new()
    	var err = peer.create_server(PORT, MAX_CLIENTS)
    	if err == OK:
    		get_tree().network_peer = peer
    func create_client():
    	var peer = NetworkedMultiplayerENet.new()
    	var err = peer.create_client(IP_ADDRESS, PORT)
    	if err == OK:
    		get_tree().network_peer = peer
    func create_player(ID):
    	var player_instance = preload("res://Player/Player2D.tscn").instance()
    	player_instance.name = str(ID)
    	player_instance.position = Vector2(rand_range(0, 360), rand_range(0, 240))
    func get_ids():
    	my_id = get_tree().get_network_unique_id()
    	peer_ids = get_tree().get_network_connected_peers()
    func connected():
    func disconnected():
    func peer_connected(id):
    func peer_disconnected(_id):

Here’s the Actor script

extends Node2D

var speed : int = 300
var vel : Vector2 = Vector2.ZERO

remote var puppet_position : Vector2 = Vector2.ZERO
remote var puppet_rotation : float = 0

func movement_control():
	if Input.is_action_pressed("move_forward"):
		vel.x = speed
		vel.x = 0

remote func set_pos_and_rot(pos, rot):
	rset_unreliable("puppet_position", pos)
	rset_unreliable("puppet_rotation", rot)

And, Here’s the Player code:

extends KinematicBody2D

const speed : int = 400

var velocity : Vector2

func _ready():

func _if_is_master() -> bool:
	if name == str(Network.my_id):
		return true
		modulate = Color8(255, 0, 0, 255)
		return false

func _physics_process(delta):
	if _if_is_master() == true:
		if Input.is_action_pressed("ui_up"):
			velocity.x = speed
		look_at(get_global_mouse_position()) # No need to care about this now
		var _movement = move_and_slide(velocity)
		rpc_unreliable("sync_pos", position)

puppet func sync_pos(pos):
	position = pos

And also the main_menu_script if you need:

extends Control

func _on_Host_pressed():

func _on_Join_pressed():