Files
Godot_2D_MP_Base/2d_mp_base/scripts/GameManager.gd
2026-05-22 23:28:18 -05:00

18 lines
492 B
GDScript

extends Node
const BALL = preload("uid://dpcnrigmslqkt")
var current_level: Node
var chat_node: Chat
@rpc("any_peer", "call_remote", "reliable")
func request_spawn_ball(pos: Vector3):
if is_multiplayer_authority():
_spawn_ball(pos, multiplayer.get_remote_sender_id())
func _spawn_ball(pos: Vector3, sender_id: int):
var new_ball: Node3D = BALL.instantiate()
new_ball.name = "Ball_%d_%d" % [sender_id, randi()]
current_level.add_child(new_ball, true)
new_ball.global_position = pos