wo997 Posted February 27, 2017 Share Posted February 27, 2017 First of all here is my project, controls are WASD and mouse. http://playground.babylonjs.com/#11OMIX#26 I was wondering what is causing some kind of friction between the ground and a tank, try to press A or D for 5 seconds, it will not turn smoothly, I noticed that the glitch occurs when the tank is on X or Z axis (probably also on Y axis too but I didn't try). You can see that wheels are rotating propertly, there are no forces pushing the hull, just wheels are jointed to it. Any ideas? Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 27, 2017 Share Posted February 27, 2017 Hi, that is a wonderful scene! Wow, very impressive. To me it seems like the wrong calculation of the forces to apply. You are using somewhere sin-based calculation like tan (without getting too deep into the code) which resets when reaching the 0's of the axes. Does it make somehow sense? Quote Link to comment Share on other sites More sharing options...
wo997 Posted February 27, 2017 Author Share Posted February 27, 2017 @RaananW Thanks. No, I'm not using any forces that are calculated with sin or tan functions, I am just setting the motor force of each hinge joint between wheels and hull to the value calculated with 2 parameters, speed and rotation, nothing special. Friction makes it moving. I tried to remove the turret but this doesn't change anything. Quote Link to comment Share on other sites More sharing options...
wo997 Posted February 27, 2017 Author Share Posted February 27, 2017 @RaananW I removed rotation quaternion of the hull mesh for an experiment, but with no success Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 27, 2017 Share Posted February 27, 2017 to me it seems like the calculation of the motors is a bit odd (speed + rotation and speed - rotation), but again - i can't pinpoint the exact point where it is wrong. Any possible way of simplifying the playground so we can together pinpoint the problem (and learn a lot )? Quote Link to comment Share on other sites More sharing options...
wo997 Posted February 27, 2017 Author Share Posted February 27, 2017 @RaananW Well, I will try Give me a few minutes Quote Link to comment Share on other sites More sharing options...
wo997 Posted February 27, 2017 Author Share Posted February 27, 2017 @RaananW finally... http://playground.babylonjs.com/#11OMIX#27 I could remove some more objects, but I decided to leave it as it is now. Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 27, 2017 Share Posted February 27, 2017 @wo997 - so ,.. this drove me a bit crazy It seems to be related to the forces calculations of the physics engine when the wheels are positioned where you positioned them. I am very disappointed I don't have a better explanation! Having said that! http://playground.babylonjs.com/#11OMIX#28 . if you put the wheels closer together (or if you make the hull a bit wider) it is solved. Quote Link to comment Share on other sites More sharing options...
wo997 Posted February 27, 2017 Author Share Posted February 27, 2017 @RaananW I can still see it's wiggling (less but still), it is not solved - I think it may be a problem with friction combined with joints, but belive me, the problem occured also for a cube sliding on a ground, when there was no wheels at all. So yeah... it's terrible Quote Link to comment Share on other sites More sharing options...
fenomas Posted February 28, 2017 Share Posted February 28, 2017 Can you please post an example of this happening for just a cube sliding on the ground? It sounds to me like some kind of nasty anisotropic bug inside Cannon. Quote Link to comment Share on other sites More sharing options...
wo997 Posted February 28, 2017 Author Share Posted February 28, 2017 @fenomas It will take me a lot of time to do, but if you want it then I will try I may have a little trouble with switching it back though. Quote Link to comment Share on other sites More sharing options...
fenomas Posted February 28, 2017 Share Posted February 28, 2017 @wo997 Well, I didn't mean it would necessarily need to derive from your scene. In fact I think it would be better not to, as a minimal reproduction is ideal. I mean, if you started with a minimal scene, like this: http://playground.babylonjs.com/#24QL2E#0 what is the minimum that needs to be done to show the behavior? From your scene, I can't really guess if the bug is with how joints work, or how the motors work, or how the friction force gets transmitted through constraints, or what. Quote Link to comment Share on other sites More sharing options...
wo997 Posted February 28, 2017 Author Share Posted February 28, 2017 @fenomas @RaananW I got the simplest possible scene http://playground.babylonjs.com/#24QL2E#1 I have only added a script that changes direction and pushes the body along its rotation matrix, nothing special but the glitch is visible. I think that friction is just wrongly programmed in cannon.js but I hope there is a solution. Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 28, 2017 Share Posted February 28, 2017 This is a different implementation of what you showed before. In this case you are using babylon's rotation to simulate the body's rotation and not motors. I am also not seeing the glitch really. Quote Link to comment Share on other sites More sharing options...
wo997 Posted February 28, 2017 Author Share Posted February 28, 2017 @RaananW I forgot to say you have to press Q/E to rotate the mesh (try different angles, f.e. 35 degrees from start position), then the direction of friction force is wrong, it shouldn't go sideways, but forward. The bug is there, I am 100% sure. 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.