Basically I'm trying to convert my game to work with multiplayer. Players control a spaceship and can fire lasers, and I have some code that detects which player shot the laser to do some damage calculations and other stuff. When the client player shoots, on the host players side the client player is detected as an EncodedObjectAsID, not as a KinematicBody, which is basically game breaking.
I'm still pretty new to the engine and understand very little about networking, so I'm not sure what i can do about this.
in game client shooting responses:
client side: laser shot by: [KinematicBody2D:1959]
host side: laser shot by: [EncodedObjectAsID:2913]
laser firing code:
func fire(body):
if online && is_network_master() && can_shoot && Input.is_action_just_pressed(shoot):
fire_code(body)
print(body)
rpc("fire_code", body)
elif !online && can_shoot && Input.is_action_just_pressed(shoot):
fire_code(body)
remotesync func fire_code(body):
var laser = LASER.instance()
laser.connect("laser_hit", other_player, "take_damage")
laser.shot_by = body
print("laser shot by: ", laser.shot_by)
get_parent().add_child(laser)
laser.position = $bullet_spawn.global_position
laser.set_direction(shoot_direction)
can_shoot = false
emit_signal("laser_fired")
Global.create_timer(laser_cooldown, body, "reactivate_laser", true)