[physics] Reset position of mesh with gravity

My object is this.

  • parent = Mesh - PhysicsImpostor : box, mass : 0, restitution : 0.5
    • child 2 = Original mesh;
    • child 1 = Collider mesh - PhysicsImpostor : no Impostor, mess : 1, restitution : 0.5

And, I want drop my object when clicked some button.
I’m tried many time but, object is don’t moving or move to strange position.
When sometime, my fixed position was initialized after 10~10+X frame.

Next is one example copied at PG.
PG : https://www.babylonjs-playground.com/#XCPP9Y#1224

Please! :pray:

Hi,

I’m starting in Babylon but I think I found some improvement.

https://www.babylonjs-playground.com/#XCPP9Y#1226

I changed the way of creating the compound body. I don’t know what position you want for the child so I kept the same. I also added a physics plugin. This allow collision with your ground.
When creating a compound body, the order you do things is very important : Create Compound Bodies - Babylon.js Documentation.

I had collision but the object was falling at full speed and rotating. I added a vector3 for the position but I also reseted the position and most important the velocity, angular and linear.

I hope this is the behaviour you want :).

3 Likes

Thank you!
Very fast your answer.
And your code was nice reference.
I’m replaced location of ‘root’ after objects position setting.

Thanks again! :+1:

1 Like