Multiplayer With Physics Structure

I’ve tried searching for a way to make a multiplayer game with physics with socket.io. My attempts were unsuccessful. I’ve tried just updating the rigidbody position if the player interacts with any dynamic objects (like picking up (it floats in front of player)) to the clients. It didn’t go well. Some objects were in different places? I used get and set position.

I just need to know how I can get physics and multiplayer to work and the structure of the server and client.

I also need to know how I can achieve an AI on the server (trying to make a nextbot game).
I don’t want all stress to be on one player’s client (updates go to him and then to everyone bc physics) but if it’s necessary, then I’m willing to do so.

I honestly don’t care about cheating or high precision because that’s what makes it fun (and easy to code).

Here is the project that I was working on and the server.
It’s a mess… :grinning:

Hi @Frenchie!

The main problem here is that you can’t use setPosition() and setRotation() on entities with a dynamic rigidbody. It only changes the visual entity but not the rigidbody of it.

image

You can try to use entity.rigidbody.teleport(pos, rot) instead.

Oh! I totally forgot about that! I’ll try that soon.

1 Like