I have a scene with a “ground” moving below the “player”, everything is working as I want, but not as I expected, I mean, does the moving ground shouldn’t affect the cylinder, moving it to the left?
I’ve also tried to add some friction to it, but don’t work either. How could I make the ground affect the mesh above?
Hey @Moriy thank you for the tips and the playground fix! But why is needed to add more lines of code to achieve this? This is bugging me cause I thought the cylinder would move to the same direction as the ground, just like a moving mat, as we add physics impostor to both the meshes (ground and cylinder), shoudn’t the cylinder flow with the ground without any more code?
I mean, why do we need to add a velocity on the physicsImpostor and change the mesh position too? I come from unity (but still now much experience) and there, when I move an element to the left, any other elements physically above this element follow the position of the below element, just like if I have a box with an apple above the box, the apple should still above the box, despite the direction I move the box, right?
Do you know why this isn’t the behavior of babylonjs? I would like to understand this if possible so if you could explain or point out where on the docs have some explanation about this would be great
It looks like an issue is that if the physics impostor’s mass is 0, then its corresponding mesh object is not moved by setting linearVelocity on the physics impostor.
For example, here’s a simple playground example of a sphere whose physics impostor has mass 1 being moved by setting its linear velocity.
And here’s the same playground with the mass changed to 0, and in this case the sphere doesn’t move (like your ground mesh whose impostor also has mass 0).
IDK what the solution is thou, because just changing your ground impostor’s mass from 0 creates lots of other complications…
But it def seems like you should be able to comment out lines 144 and 145 that move the mesh manually, and just use the linear velocity to move both the impostor body and the mesh. IDK how to configure the impostor settings properly to achieve it thou… https://playground.babylonjs.com/#2DIDW2#9
I think it is probably that your ground’s mass is zero, and your ground and player both are rigidbody, according to physic’s conservation of momentum, ground don’t has mass, it can not provide the decrease momentum to player?
yes, I think moving an impostor with code has no influence on contacts with other impostors. For the physics engine, nothing happens (as the ground is static) and collision happen at the same world position each frame.
Adding a force/impulse/linear velocity will make the contact different and you should see an interaction with the capsule.
That said, I agree the nature of static impostor is to be static.