godotengine / godot

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

Node disappears in network multiplayer on physics collision and game crashes #25684

Closed ScyDev closed 4 years ago

ScyDev commented 5 years ago

Godot version: 3.0.6.stable.official.8214054

OS/device including version: Ubuntu 18.04 64bit

Issue description: If I run my game on two PCs across my WiFi, if two units cause a physics collision with each other, one of the units just disappears from both clients (I have not coded any such behavior). Most of the time, the client will become disconnected from the server soon after that.

The trigger is: setting the scale of a RigidBody with rset_unreliable("slave_scale", self.scale) and self.scale = self.slave_scale.

If I run two instances of my game on the same PC and test multiplayer that way, this does NOT happen. Happens only on a real network, cable or wireless.

I am aware that Godot doesn't want RigidBodies to be scaled, or just resets the scale to (1, 1, 1). That's okay if there is a good reason for that. But it should not behave in such an erratic way, without a specific error.

Steps to reproduce:

  1. Run the game on two PCs
  2. Host. Join on IP. Start.
  3. Move the starting unit of each player towards each other until they collide. Select with left click, move with right click.
  4. Disable slave setting of scale on the following lines and see that the error doesn't happen anymore: 4.1 https://gitlab.com/ScyDev/Critically-Entangled/blob/debugging/physics-collision-with-slave-scale-crashes/godot-project/Unit.gd#L57 4.2 https://gitlab.com/ScyDev/Critically-Entangled/blob/debugging/physics-collision-with-slave-scale-crashes/godot-project/Unit.gd#L102 4.3 https://gitlab.com/ScyDev/Critically-Entangled/blob/debugging/physics-collision-with-slave-scale-crashes/godot-project/Unit.gd#L106

Minimal reproduction project:

Use this tag of my project: https://gitlab.com/ScyDev/Critically-Entangled/tree/debugging/physics-collision-with-slave-scale-crashes

Faless commented 5 years ago

@ScyDev you have slave var slave_scale = Vector3() (i.e. 0 scale by default). This gets assigned to the objects scale at some point, which seems to make physics angry (causing the ERROR: move: Condition ' Math::is_nan(p_aabb.size.x) ' is true. spam). Change that to slave var slave_scale = Vector3(1,1,1) (i.e. scale 1 by default) and the error goes away.

Not sure if this is an actual bug (are 0 scaled elements allowed in physics?) but in case my guess is that it's more a physics bug then a network one.

Faless commented 5 years ago

@AndreaCatania ?

akien-mga commented 4 years ago

There was no follow up, but yes, using a scale of 0 is definitely going to lead to issues with physics and rendering. The editor should now prevent it to some extent / raise warnings.

ScyDev commented 4 years ago

@Faless Thanks a lot!