This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

hello everyone,
everytime i join my multiplayer game, i get this error 14 times. i used this networking tutorial to set up my project (the network script is almost the same)

this is my player code, i have already commented the "defective" lines:

extends KinematicBody
const speed=15
const mouse_sens = 0.5
onready var anim_player = $AnimationPlayer
onready var raycast = $RayCast
var gravity=-12
var weapon = 0 
var life=5
var bullets=0
var maxbullets=1
var nickname = ""
var peernumber = 2 #used for spawners, it doesnt work yet


puppet var slave_pos= Vector3()
puppet var slave_movement = Vector3()

func _ready():  #ignore
    bulletsnumber() 
    Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func bulletsnumber(): #ignore
    match weapon:
        0:maxbullets=6
    bullets=maxbullets

func _input(event):  #ignore
    if event is InputEventMouseMotion && is_network_master():
        rotation_degrees.y -= mouse_sens + event.relative.x


func _process(delta):  #ignore
    if Input.is_action_pressed("exit") && is_network_master():
        get_tree().quit()

func _physics_process(delta):
    var move_vec = Vector3()
    if is_network_master():
        if Input.is_action_pressed("move_forwards"):
            move_vec.z-=1
        if Input.is_action_pressed("move_backwards"):
            move_vec.z+=1
        if Input.is_action_pressed("move_left"):
            move_vec.x-=1
        if Input.is_action_pressed("move_right"):
            move_vec.x+=1

#this is the defective line of code, i don't know why!
rset_unreliable('slave_pos', self.translation)
        rset('slave_movement', move_vec)
    else:
        translation = slave_pos
        move_vec=slave_movement

    if move_vec.x != 0 or move_vec.z != 0: 
        $playerskin.play("walking1")
    else: 
        $playerskin.play("idle1")

    move_vec.y += gravity * delta
    move_vec=move_vec.normalized()
    move_vec = move_vec.rotated(Vector3(0, 1, 0), rotation.y)
    move_vec = move_and_slide(move_vec*speed, Vector3(0,1,0))
    #shoot

    if get_tree().is_network_server():
        Network.update_position(int(name), translation)

    if Input.is_action_pressed("shoot") and !anim_player.is_playing() and is_network_master(): 
        if bullets>0:
            bullets-=1
            anim_player.play("shoot"+str(weapon))
            var coll=raycast.get_collider()
            if raycast.is_colliding() and coll.has_method("hit"):
                coll.hit()
        else:
            anim_player.play("reload"+str(weapon))
            bullets=maxbullets


func hit():  #ignore
    life-=1
    if life<=0:
        rpc("die")

sync func die():  #i know it's bad, ignore
    queue_free()

func init(peernickname, is_slave): #activated when the player spawn via the network script
    nickname = peernickname
    $nameviewport/Control/Label.text = nickname
    if is_slave: #this is a fps game, so i deactivate the puppet's camera
        $Camera.current=false
    else:$Camera.current=true

    peernumber = Network.players.size() #doesn't work yet <code>
    self.translation = get_node("/root/world/spawner"+str(peernumber)).translation

thanks in advance

in Engine by (16 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.