I’m having trouble with the physics impostor.
When I apply impostor on both children and parent, like this -
I get a warning:
Although, I’m affecting imposters to children before affecting imposter to parent, right? (line #20 and line #71)
But, if I remove imposter from all the children (line #20), the object goes haywire:
What is the best way? Please help
To make a physics car, do not parent mesh but create joints that link the impostors.
See this documentation and related example PG :
Joints | Babylon.js Documentation
Also, you should be able to find PG that build physics car quite easily.
Thanks… But I’m just importing an already created 3D model which contains 7 meshes and so, I’m grouping those meshes into a parent mesh.
You can try to dispose every mesh like in this PG:
dispose every mesh | Babylon.js Playground
check line 29
I don’t quite understand how that might help me. Please explain
Sorry, I replied in the wrong topic !
Mesh parenting is for rendering is scene graph hiearchy. It doesn’t automatically create physics joints.
To make a car, you have to set joints between the wheel and the chassis.
Front wheels and back wheels might not have the same joint properties.
Once you’ve loaded your mesh, create impostors for each one then link them together with joints.
See this car example:
And another demo with cannon
test | Babylon.js Playground (babylonjs-playground.com)
Or this one :
cannon car physics wheels | Babylon.js Playground
Check line 46 on how to create hinge joint
Hi @mapkbalaji ,
I can see you are still working hard on your case
My feeling is that you should may be restructure your project (working the order of steps). You have spent a while now struggling with a model (where does it come from?) that seems inappropriate to use as such.
Last time I saw your PG, you were far from having set 1) your scene 2) your map 3) your objects 4) the physics of the game object (the car).
I’d say all you need at this stage to represent your car and work your scene/gameplay (AND physics!) is what is shown in the examples from @Cedric .
You need 4 wheels, 2 axes for the rear and front wheels, a cube representing the chassis and last a center of mass and a mass (ideally;). Once you have all this working correctly in your scene, it will piece of cake to replace the objects with the appropriate mesh/submeshes of your model. If you do this the other way round, you might get into additional trouble. A time you could spend elsewhere in your project for an even better result. My opinion only. Feel free to disregard… no worries and again GL.