Puck Posted May 29, 2018 Share Posted May 29, 2018 Playground demonstrating the issue: https://playground.babylonjs.com/#9JSLE2 Explanation: I'm trying to create a simple walk around scene and the built in collision system seems to work pretty darn well (Who needs a physics engine anyway?) but I've noticed that when I add any kind of slope the camera will slide down it -- in a real hurry too if gravity is set realistically! I noticed that this doesn't happen with the stairs in the Espilit demo, but looking at the scene file and demo.js I can't figure out how it's managing that. Is there a friction setting or something that I can set for objects like stairs and ramps? Quote Link to comment Share on other sites More sharing options...
Guest Posted May 29, 2018 Share Posted May 29, 2018 Hello the collision engine uses A LOT of approximation to perform well and thus the gravity cannot be set to a realistic value most of the time. I suggest you set it to a lower value and it should fix your problem Puck 1 Quote Link to comment Share on other sites More sharing options...
Puck Posted May 29, 2018 Author Share Posted May 29, 2018 Thanks for replying as always! So beyond making (possibly significant) adjustments to the collision system there's no real solution? I tried a very small value for gravity (0.03) and still experienced sliding, though the camera does seem to "stick" after sliding a certain amount. Unfortunately it also has the expected side effect of making the camera fall very slowly when walking off an edge. What I would really like is to be able to set some kind of "sticky" or "friction" value on a per mesh basis that prevents the camera from sliding relative to that object when they are touching. That way I could set sticky for surfaces the player should be able to stand on like stairs, while still allowing sliding for surfaces the player isn't meant to walk on. It would be super useful for moving platforms as well! I'll take a look at the collision code myself. Advanced math really isn't my forte, but Babylon has a great code base so maybe those parts will be abstracted well enough that I can still muck around with it. Quote Link to comment Share on other sites More sharing options...
Guest Posted May 29, 2018 Share Posted May 29, 2018 Most of the collision code is here: https://github.com/BabylonJS/Babylon.js/blob/master/src/Collisions/babylon.collider.ts and more precisely, you should tweak this function to change the response when a collision occurs: https://github.com/BabylonJS/Babylon.js/blob/master/src/Collisions/babylon.collider.ts#L360 (something like reducing the length of vel vector) Quote Link to comment Share on other sites More sharing options...
Puck Posted May 29, 2018 Author Share Posted May 29, 2018 Perfect. Thank you @Deltakosh! I'm finally gonna fork the engine this evening and take a look at that, as well as properly integrate the Ammo.js plugin I jury rigged. If I come up with anything useful I'll send back a pull request on Github. Quote Link to comment Share on other sites More sharing options...
Guest Posted May 30, 2018 Share Posted May 30, 2018 I hope so Quote Link to comment Share on other sites More sharing options...
gorgar Posted July 17, 2018 Share Posted July 17, 2018 @Puck Did you find a solution to the sliding? I've made good progress on a FP character controller - but dealing w/ the slope sliding now. 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.