bfarisdev Posted September 3, 2018 Share Posted September 3, 2018 Hi there! I'm creating a game that currently uses a simple physics based system. A sphere is controlled by the player and moves around a world (ground generated with a heightmap). Everything works perfect until the ball falls from a very tall height. The collision detected stops working and the ball falls right through the ground due to the high velocity. Here is the code associated with the objects: var sphere = BABYLON.MeshBuilder.CreateSphere("sphere", {diameter: 1}, scene); sphere.physicsImpostor = new BABYLON.PhysicsImpostor(sphere, BABYLON.PhysicsImpostor.SphereImpostor, { mass: 1, restitution: 0.3 }, scene); var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "./res/height6.png", worldSize, worldSize, 200, 0, 50, scene, false, function () { ground.physicsImpostor = new BABYLON.PhysicsImpostor(ground, BABYLON.PhysicsImpostor.HeightmapImpostor, { mass: 0 }); }); I was wondering if someone can point me in the right direction for how I should go about solving this behavior. It is necessary that the collision detection works for high velocity collisions in my game. Best regards, Brian Quote Link to comment Share on other sites More sharing options...
brianzinn Posted September 4, 2018 Share Posted September 4, 2018 Welcome to the forum! I think you are using collision frame detection and you need continuous (predictive) collision detection. In other words, when the frame before and after the actual collision render, there are no collisions. I'm not sure how to answer your question as you are using a heightmap. Some people have made thicker ground or changed the world dimensions, but I don't think that will address high velocity heightmap. Hopefully somebody else has a solution. Which physics engine are you using? I think cannonJS has support for that at least on certain Impostors - we may need a PG (Playground). Quote Link to comment Share on other sites More sharing options...
Guest Posted September 4, 2018 Share Posted September 4, 2018 Hello! I felt into this problem some times ago. The best option is to make your ground thicker (like give it some height instead of using a pure plane) Other option is to set the scene.getPhysicsEngine().setTimeStep(1 / 120) to make it more precise Quote Link to comment Share on other sites More sharing options...
bfarisdev Posted September 4, 2018 Author Share Posted September 4, 2018 2 hours ago, Deltakosh said: Hello! I felt into this problem some times ago. The best option is to make your ground thicker (like give it some height instead of using a pure plane) Other option is to set the scene.getPhysicsEngine().setTimeStep(1 / 120) to make it more precise Setting the timestep worked perfectly! For others that do not have luck, can you post the function for increasing the ground thickness? (I've tried ground.depth with no luck and didn't see an imposter thickness function. Height seems to only adjust the elevation). Quote Link to comment Share on other sites More sharing options...
Guest Posted September 4, 2018 Share Posted September 4, 2018 I cannot as you will have to create the mesh manually 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.