godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.7k stars 20.12k forks source link

MultiplayerSynchronizer and players sharing collider layer causes undesirable spawn location #91005

Open LexGear opened 4 months ago

LexGear commented 4 months ago

Tested versions

Reproduced in Godot 4.2.1

System information

Windows 11 - Godot 4.2.1

Issue description

When setting up a simple local network fps game, I discovered that if players share the same collider layer, regardless of where the first player is currently when the second player joins, the new player will appear in either a seemingly random location or on top of the last-player-to-join's head.

I believe this is due to the very first frame on the joining clients end where both players occupy the same 0, 0, 0 location before the MultiplayerSynchronizer has had a chance to position the players retrospectively.

Steps to reproduce

Create a simple network capible game using a MultiplayerSpawner node, a simple flat plane, and a player scene containing:

Minimal reproduction project (MRP)

You can use https://github.com/devloglogan/MultiplayerFPSTutorial project as an example, but you need to set the player collider layer to 1 so that every player shares the same collider layer.

sleepyghostdev commented 3 months ago

Are there any good work arounds for this?

LexGear commented 3 months ago

Are there any good work arounds for this?

In my case, what I did was to simply remove collisions with players. This worked out okay for me because I replaced it with a little bit of code to give the players a soft push away from each other instead of it being rigid.

Jay-ArBrouillard commented 2 months ago

@LexGear Can you share any code on your work around? I have the same issue with my project. Turning off the collision mask on my player "fixes" as you mentioned but now I don't have collisions between players.