• Content Count

  • Joined

  • Last visited

About Anemol

  • Rank

Contact Methods

  • Website URL
  • Twitter

Profile Information

  • Location
  1. To stay in the continuity of the subject, some lines of code that can be useful to measure the force of impact during a collision (to handle dammage/health for example): player.wheel.physicsImpostor.physicsBody.addEventListener( "collide", function ( e ) { var relativeVelocity =; });
  2. Now I am interested in the communication part. for building my game. I thought to run the physical engine on the server and client(s) but it seems very complex to synchronize all objects and there must be a lot of data to transmit (position, rotation, quaternion, velocity and problably more). I'm focusing on the simplicity: physics on the server only and rendering on clients (so, just the meshes). On the other hand, to avoid jerks effect, i will need to be able to render the meshs with a smooth effect: i have a mesh at (positionA,orientationA) and have to display it at (positionB,orientationB) in T milliseconds. Any ideas to do this?
  3. Just a question of luck. I printed physicsImpostor into the console for checking the params/methods about "inertia". I hope i will fix your scenario too.
  4. Thank you for the help and advice provided. Effectively, I had read that there were problems with the scaling method. I thought possibly fill the foliage of the tree with several small spheres to match up the real shape (or maybe a joint) Another question that is a little off-topic with the initial subject but bounces on another subject that i had already opened. Still with the Cannon plugin, i have an object composed of a box, a wheel (the motor) and a hinge joint. I have a server who is running a scene (null engine) and i have to update the client scene. I was wondering what is the essential information to broadcast to properly update the object in the client scene, and if there was a specific method for that use. For example, i was looking at which talks about serializing information, but what would be the information to serialize and especially for a complex object like mine? ( position, angular/linear velocity, quaternion only?)
  5. I having a problem with the "Compounds and Babylon's parenting system". I create 2 types of trees. Both are using a box + a sphere. For the second type, the sphere has a diameterY option but the physics engine (Cannon) sees it as a sphere with a diameter=diameterY Is it normal or is it a bug?
  6. The adventures continue... 😉 With the addition of 'invInertiaWorld', the box remains vertical. player.holder.physicsImpostor.physicsBody.inertia.setZero(); player.holder.physicsImpostor.physicsBody.invInertia.setZero(); player.holder.physicsImpostor.physicsBody.invInertiaWorld.setZero(); The playground: Now, i would like to orient (axe Y) the box/wheel impostors according to the direction of the camera . I quickly tested some bits of line but without success. quaternion.setFromAxisAngle() seems not working. Edit: Impostors can rotate with angularVelocity.y / playground edited. Arrow keys + Space for jumping
  7. How to faithfully update the mesh position for which follow the evolution of the physicsImpostor? In this playground i did like that , but isn't ok. player.mesh.position.x = player.holder.position.x; player.mesh.position.y = player.holder.position.y-30; player.mesh.position.z = player.holder.position.z; var euler = player.holder.rotationQuaternion.toEulerAngles(); player.mesh.rotation= new BABYLON.Vector3(euler.x, euler.y, euler.z);
  8. I have already created a multiplayer game (little game without any pretensions) that has been running for a few years now, with ThreeJS/NodeJS: LWOS But it's a 2D game internally, despite the 3D aspect. So i wanted to migrate to real 3D environment. I have no talent in designing videos, and I support myself, as many from example found that I fit according to my own needs I don't have any particular knowledge in the design of video games, so, like many i think, i use the tutorials/examples found then i adapt them to my needs. I'm continuing to searching, but i am still surprised not to find more example than that.🤔 @QuintusHegie : Thank you. I started to watch this part a little too. 🙂 It is expected that the players can collect items, and i thought to use the detection of colision precisely to manage this part there (so the items will not be included in the physic). But for the moment, it's secondary. @Deltakosh : Yes, already saw it. But the case of a car is not interesting,i think, the car will follow the movement of the ground. Normally, in my case, the player mesh must remain vertical. I keep searching. Stay to find the right constraint / type of joint. Missing something to constrainst the holder to rotate only on Y axe.
  9. I tried to adapt this part of the code, but it gives nothing good. I used the rabbit as mesh, not knowing if it is possible to import external mesh (but that doesn't change the problem i think). (sorry, fist time i use the playground) Is not there way to use the latest versions of Babylon & Cannon (or Oimo) to reproduce this principle, more simply? If i understand correctly, it need an impostor box and an impostor sphere (the motor), and a constraint to prevent the box from bowing. Then, it is necessary to update the position/orientation of the mesh according to the box.
  10. The source aren't directly available but i watched the game.js and the part who interests me: // load the "regular guy" model BABYLON.SceneLoader.ImportMesh("", "images/models/", "regularGuy.babylon", scene, function (newMeshes, particleSystems, skeletons) { // optional - position and size the mesh var mesh = newMeshes[0]; mesh.position.y = 26; = new BABYLON.Vector3(0, 0, 0); camera.setPosition(new BABYLON.Vector3(0, 0, 10)); that._meshRegularGuy = mesh; // begin the standing animation that._skeletonRegularGuy = skeletons[0]; scene.beginAnimation(that._skeletonRegularGuy, 31, 60, true, 1.0); shadowGenerator.getShadowMap().renderList.push(mesh); // create the physics bodies representing the dude var regularGuyBox = BABYLON.Mesh.CreateBox("regularGuyBox", 1, scene); regularGuyBox.scaling = new BABYLON.Vector3(1, 2, 1); regularGuyBox.position = new BABYLON.Vector3(mesh.position.x, mesh.position.y + 6.3, mesh.position.z); regularGuyBox.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: 1, friction: 0.5, restitution: 0.1 }); regularGuyBox.visibility = _showPhysicsDebugObjects; that._regularGuyBox = regularGuyBox; // get the physics body reference of the box that._regularGuyBoxBody = scene._physicsEngine._registeredMeshes[scene._physicsEngine._registeredMeshes.length - 1].body; that._regularGuyBoxBody.inertia.set(0, 0, 0); that._regularGuyBoxBody.invInertia.set(0, 0, 0); // create the "leg" for kicking that._regularGuyKickLegBox = BABYLON.Mesh.CreateBox("regularGuyKickLegBox", 1, scene); that._regularGuyKickLegBox.visibility = _showPhysicsDebugObjects; that._regularGuyKickLegBox.scaling = new BABYLON.Vector3(1, 1, 1); that._regularGuyKickLegBox.position = new BABYLON.Vector3(mesh.position.x, mesh.position.y + 5, mesh.position.z - 1.2); // create the "wheel" that the guy moves on that._regularGuyBoxWheelSphere = BABYLON.Mesh.CreateSphere("regularGuyWheel", 10, 1, scene); that._regularGuyBoxWheelSphere.visibility = _showPhysicsDebugObjects; that._regularGuyBoxWheelSphere.position = new BABYLON.Vector3(mesh.position.x, mesh.position.y + 4.8, mesh.position.z); that._regularGuyBoxWheelSphere.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 1, friction: 0.5, restitution: 0.1 }); // get the physics body reference of the wheel that._regularGuyBoxWheel = scene._physicsEngine._registeredMeshes[scene._physicsEngine._registeredMeshes.length - 1].body; // create the hinge (joint) and motor for wheel var leftAxis = new CANNON.Vec3(0, 1, 0); var leftFrontAxis = new CANNON.Vec3(0, 1, 0); that._regularGuyBoxWheelConstraint = new CANNON.HingeConstraint(that._regularGuyBoxBody, new CANNON.Vec3(0, 0, -1.5), leftFrontAxis, that._regularGuyBoxWheel, new CANNON.Vec3(), leftAxis) scene._physicsEngine._world.addConstraint(that._regularGuyBoxWheelConstraint); that._regularGuyBoxWheelConstraint.enableMotor(); // hide the loading divs document.getElementById("divLoading").style.display = 'none'; document.getElementById("divLoadingMessage").style.display = 'none'; });
  11. Hello, I'm learning with Babylon.js. In the perspective of creating a little multiplayer game in 3D, with the physics engine of Ammo (see possibly Oimo). At first, i would like to be able to move the player (a exported blender mesh, but without animation) in the created world. But the player doesn't have to rock / bend. This seems pretty common but unfortunately, after long hours of research on the Internet, i haven't found any tutorials/examples that i could use and inspire me. There is really a lot of information on Babylon, probably that i did not type the right keywords. The only one i found that matches my request, unfortunately uses an outdated version of Babylon.js 😞 (i'm using a recent version) : Apparently, as show the image, it requires a motor (wheel) and a constraint (joint). Would someone have a link on a tutorial or an example to give me? 😊 Thanks.