Godot Version
4.5
Question
Followed this tutorial exaclty : https://youtu.be/YnfsyZJRsL8
Any idea why this happens ? I’m new to networking in general :
4.5
Followed this tutorial exaclty : https://youtu.be/YnfsyZJRsL8
Any idea why this happens ? I’m new to networking in general :
Please share your code, as preformatted text between the 3 backticks ``` so that it’s formatted properly.
I don’t know what’s up with that tutorial. I made it in 2D and I think I had the same issue, and I couldn’t move any of the players. I haven’t touched networking ever since.
Are you 1000% sure you didn’t just accidentally write the position instead of the ID or something?
Here my code :
# Network Manager. Global script is actually called Sandbox.gd
extends Node3D
var peer: ENetMultiplayerPeer
func server():
peer = ENetMultiplayerPeer.new()
peer.create_server(42069)
multiplayer.multiplayer_peer = peer
func client():
peer = ENetMultiplayerPeer.new()
peer.create_client("localhost", 42069)
multiplayer.multiplayer_peer = peer
# Multiplayer Spawner
extends MultiplayerSpawner
@export var multiplayer_player: PackedScene
func _ready() -> void:
multiplayer.peer_connected.connect(spawn_player)
func spawn_player(id: int) -> void :
if !multiplayer.is_server() : return
var player: Node = multiplayer_player.instantiate()
player.name = str(id)
get_node(spawn_path).call_deferred("add_child", player)
# Player script
extends CharacterBody3D
@export var move_speed = 12
func _enter_tree() -> void:
set_multiplayer_authority(name.to_int())
func _physics_process(_delta: float) -> void:
if !is_multiplayer_authority(): return
var direction = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
direction *= move_speed
velocity.x = direction.x
velocity.z = direction.y
move_and_slide()
# Menu
extends Control
func _on_host_pressed() -> void:
hide()
Sandbox.server()
func _on_join_pressed() -> void:
hide()
Sandbox.client()
Here is the tree setup :
Thank you a lot for your time and patience
Nice ghosting
Problem came from collision handling. Disabling character collision shape upon entering tree, waiting a bit, and re-enabling it solves the spawning issue. Wonder is this is a bug and I’d love to know if anyone encountered this
Im too, and can you show how you do this?