timetocode Posted May 3, 2018 Share Posted May 3, 2018 I'm attempting to use NullEngine in node.js as a component of the server side simulation for a multiplayer game. When using *just* NullEngine + nengi.js (a multiplayer engine) mesh intersection and rays work great. I can get somewhere in the realm of 50-150 ccu (that's players, not NPCs). The performance is really awesome. Now I'm trying to get some more advanced physics in place. However when I attempt to include OimoJSPlugin on the serverside I get " TypeError: Cannot read property 'World' of undefined " const BABYLON = require('babylonjs') let engine = new BABYLON.NullEngine() let scene = new BABYLON.Scene(engine) let camera = new BABYLON.ArcRotateCamera('Camera', 0, 0.8, 100, BABYLON.Vector3.Zero(), scene) scene.enablePhysics(null, new BABYLON.OimoJSPlugin()) That last line there is the one that throws the error. Any idea what I'm doing wrong? I also get a warning that 'oimo' module cannot be found (related, I presume?). I setup babylon via `npm install babylonjs` (as opposed to downloading something) and the version is 3.2.0. Thanks for reading! And BJS + NullEngine is a dream come true! Quote Link to comment Share on other sites More sharing options...
timetocode Posted May 3, 2018 Author Share Posted May 3, 2018 I also tried another way, where I downloaded a custom build of babylon.js that has oimo in it, and include that from the server side. This one get slightly different errors: [0] WARNING in ./server/babylon.custom.js [0] Module not found: Error: Can't resolve 'oimo' in 'C:\Users\benne\Desktop\nengi-projects\3d\server' [0] @ ./server/babylon.custom.js 1:294-309 [0] @ ./common/entity/PlayerCharacter.js [0] @ ./common/nengiConfig.js [0] @ ./client/GameClient.js [0] @ ./client/clientMain.js This warning is the same as before. The new error is this: [1] BJS - [00:05:35]: Babylon.js null engine (v3.2.0) launched [1] C:\Users\benne\Desktop\nengi-projects\3d\server\babylon.custom.js:84244 [1] this.world = new this.BJSOIMO.World({ [1] ^ [1] [1] TypeError: Cannot read property 'World' of undefined [1] at new OimoJSPlugin (C:\Users\benne\Desktop\nengi-projects\3d\server\babylon.custom.js:84244:43) [1] at Object.<anonymous> (C:\Users\benne\Desktop\nengi-projects\3d\server\GameInstance.js:13:27) [1] at Module._compile (module.js:635:30) [1] at Object.Module._extensions..js (module.js:646:10) [1] at Module.load (module.js:554:32) [1] at tryModuleLoad (module.js:497:12) [1] at Function.Module._load (module.js:489:3) [1] at Module.require (module.js:579:17) [1] at require (internal/module.js:11:18) [1] at Object.<anonymous> (C:\Users\benne\Desktop\nengi-projects\3d\server\serverMain.js:1:84) [1] [nodemon] app crashed - waiting for file changes before starting... [0] [BABEL] Note: The code generator has deoptimised the styling of "C:/Users/benne/Desktop/nengi-projects/3d/server/babylon.custom.js" as it exceeds the max of "500KB". Quote Link to comment Share on other sites More sharing options...
Guest Posted May 3, 2018 Share Posted May 3, 2018 I guess your issue is that you need to also npm install oimo as it is an external dependency for Babylon.js BJS only contains a plugin for it but not the actual physic engine code timetocode 1 Quote Link to comment Share on other sites More sharing options...
timetocode Posted May 3, 2018 Author Share Posted May 3, 2018 Oh that makes sense. This looks like it is working. I mean I don't yet know enough physics to confirm it, but the error is gone now. I'll reply and mark as approved after a real test. Thanks GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
timetocode Posted May 5, 2018 Author Share Posted May 5, 2018 Perhaps this should be its own topic.. but does true-ish physics even make sense for something like multiplayer first person shooter? I'm the author of nengi.js which is a network engine that does relatively high concurrency (50-300 players, depending on the game) and has stuff like lag compensated shots (rewind entities by the interp delay plus the player's latency) and clientside prediction. I haven't worked in 3D or in anything particularly realistic yet, so pardon my ignorance if I'm missing a major element. It seems to me that the kind of movement needed for these multiplayer games is usually not very accurate physically -- players can change direction rapidly, sometimes we can change direction in air, etc. Also the nature of lag compensation makes it so that time isn't linear. A player with 250 ms of latency and 100 ms of interpolation needs the "physics" (or really the collision layer) to store a history of entity positions and then go back in time 350 ms to see if the laggy player's shot would connect. I presume some of this would be doable by messing with the physics steps (instead of calling it in a loop) or perhaps by creating a temporary physics world just to test for that one lag-compensated event... however as a whole it seems like realistic physics along a linear timeline isn't always going to work with advanced multiplayer features. What do you think? The desired behavior is accomplishable via simply moving meshes around and using the regular babylon collision checks. Quote Link to comment Share on other sites More sharing options...
Guest Posted May 10, 2018 Share Posted May 10, 2018 It is a good question And to be fair I don't have an obvious answer It depends a lot on what you want to achieve. but I think it can make sense for some use cases In your case it will obviously require lag compensation technique and I'm not expert in this domain unfortunately Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.