darcome Posted April 21, 2015 Share Posted April 21, 2015 Hello guys, I've added physics to the following playground: http://www.babylonjs-playground.com/#IRNRP#4 Using WASD you can move the "car" Three questions: 1) Why the wheels of the car compenetrate the "ground"? Since they are children of the box, the BoxImpostor should take them into account, or not?1) Why the car, once outside the "ground" doesn't fall?2) Why the car when collides with the box, compenetrate it and doesn't "push" it around? I suppose it's because I "move" the car with the translate function... BUt if it is the case, how do I have to move it around? Thanks in advance for your answers Quote Link to comment Share on other sites More sharing options...
darcome Posted April 21, 2015 Author Share Posted April 21, 2015 Thanks to a previous post, I found the solution forquestions 2 and 3: I have to use applyImpulse... But what about question number 1? Quote Link to comment Share on other sites More sharing options...
RaananW Posted April 21, 2015 Share Posted April 21, 2015 First - such a cool demo, I have been playing with the car for the last 10 minutes... The answer to question nr. 1 would be that oimo doesn't "know" this parent system and the plugin doesn't support that. The plugin does, however, update the physics state of parents of meshes that were registered (https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/Physics/Plugins/babylon.oimoJSPlugin.ts#L239). Enable physics state on all 4 wheels (maybe as a sphere) if you want oimo to actually know their properties. otherwise, their data is not known to the plugin and it cannot calculate their physics-state. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 21, 2015 Share Posted April 21, 2015 http://www.babylonjs-playground.com/#IRNRP#8 Fun! I created ibox... an invisible box, and parented box to IT... vertically offset line 20. ibox hits the ground, but box (the car) sits up in the air a bit. But I got the steering MESSED UP! Its all good fun! Quote Link to comment Share on other sites More sharing options...
darcome Posted April 21, 2015 Author Share Posted April 21, 2015 What do you think of this one? Now my car is driving with physics... well... almost... I think i'll have to tweak the numbers, but at least this is a starting point http://www.babylonjs-playground.com/#1LP6GO If someone can get better results, pls help me! I am very interested in it! Of course.... DRIVE WITH CAUTION!!!!!! Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 22, 2015 Share Posted April 22, 2015 http://www.babylonjs-playground.com/#IRNRP#9 Yet another, using the angular velocity setting for rotation, instead of applyImpulse. *shrug* I found it at the bottom of Temechon's tutorial... http://pixelcodr.com/tutos/physics/physics.html The problem with using applyImpulse is tire skid. ApplyImpulse essentially ignores the tires/wheels. It sort-of brings us back to RaananW's thoughts. If the wheels themselves had physicsState with sphere imposters, then you could use angular velocity on X-axis to ROLL the wheel (forward and backward movement), and use angular velocity on Y-axis for turning the FRONT wheels. (don't quote me) Then, also, tire-to-ground friction would become active and usable (road ice, snow, water, dirt, etc). In this case, likely, the best way is to use ONLY the front wheels for both turns and forward/backward, and let the rear wheels just come along for the ride. SO much trouble to get a physics car properly working, eh? *nod*. As you have probably noticed, it seems to be .translate (in your original demo) that causes the car to NOT FALL when it drives off the edge. I'm not sure if it's a bug in .translate, but maybe. This might be fixable, but until it's fixed, .translate has limited use for physics things. Oh well... we keep on "trucking" anyway, right? I just completed converting Euro Trucks 2... to BJS. (yeeeeah, you wish, Wingy) 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.