NodeJS Server question: colyseus with @babylonjs/core and havok

Hello BabylonJS Community,

I am currently developing a multiplayer game using @babylonjs/core and Colyseus. However, I’ve encountered some compatibility issues that I’m hoping to get some advice on.

Overview of the Problem:
Previously, I integrated the colyseus server with my client and it worked fine. I wanted to implement physics and movement verification on the server to prevent cheating. I’ve attempted to integrate @babylonjs/core and Havok physics with Colyseus for the server-side logic, similar to what I was doing on the client. However, I’m facing difficulties due to what seems to be compatibility issues between Colyseus and the @babylonjs/core package, specifically with the modules types ESNext & CommonJS.

Questions:

  1. Has anyone successfully integrated Colyseus with @babylonjs/core on a NodeJS server, and if so, could you share how you approached it?
  2. Essentially question 1 is my only question, but if these two packages are(n’t) actually compatible, am I just approaching this in the wrong way?

Thank you!

Maybe this can help Using Havok for a headless server

cc @RaananW as well

1 Like

Yes, see here: [OPEN SOURCE] Multiplayer 3D RPG Using Colyseus or on github: GitHub - orion3dgames/t5c: Building a open source multiplayer 3d rpg using babylon.js and colyseus.

1 Like

Thanks for the reply. I did come across that code, but the server doesn’t use @babylonjs/core.

@sebavan That post was what made me aware of NullEngine for the server. I was able to include ‘babylonjs’ rather than @babylonjs/core, and the server seems to accept it. but still have issues when it comes to using @babylonjs/loaders/glTF and similar. Is there another version of the glTF loader floating around that works similar to the ‘babylonjs’ package?

All of the @babylon/modules are also published as cjs modules under the name babylon-module. So, babylon-loaders in that case. But note that they are single files, so you wouldnt do a nested import like babylon-loader/gltf or whatever, you just import babylon-loaders and get everything.

2 Likes

Hey, I have working Havok with NullEngine where I’m importing @babylonjs/core

But it’s without Colyseus. Anyhow, maybe this will help you.

2 Likes

Thanks for the reply, I did end up doing something similar to what you have, but with the babylonjs instead of @babylonjs/core. Apart from my server’s y=0 position being 1 unit higher than the clients y=0, it seems to be working now. My server has colyseus, havok, and headless babylonjs running.

Thank you everyone for your responses!

3 Likes

Great that you have found the solution :slight_smile:
If you don’t need any more assist regarding this topic please mark one reply as the solution (might be even your reply)

1 Like