I’m wondering how to explicitly move a physics object (eg: to set its position to follow the mouse or with keyboard controls for example.) I’ve tried to do that in the PG below, but I can’t seem to move the physics shape along with a mesh (note that i’m not looking to pulse the cube around b/c I want it to move to a specific location). In this PG, my hope is that i can move the “Car” with the mouse and it will knock over the pillars.
(see lines 210)
In this screenshot you can see that i’ve moved the “Car” (grey box) to the right, but the physics body that surrounds it has not come along with it.
I’m away from my machine at the moment, but from memory, if you intend to move a physics body using the node’s position, then you need to re-enable the prestep something something on the body. The property is a Boolean and it’s called something like disablePreStep.
Missing setting with disablePrestep: Performance Tips | Babylon.js Documentation
Fixed here :
Aha! One little line. Thx so much.
One more question if you don’t mind. Why does the car pass through the blocks rather than push them around? The car is permeable, rather than a hard surface? This behavior seems different than what you see when you add a new object to the scene without explicitly moving it (like in this PG where objects don’t pass through each other)
Easier to tell here where you can move along both X and Y axis:
Ah, thats just mass/restitution settings:
Actually no i was wrong about that. It’s the spinning of the box that created more force in the last one. How do i make the “car” absolutely 100% push the object out of the way?? It’ has a very light impact on the pillars in this PG - no matter how i set mass/restitution/friction.
What i find most weird is that if the pillars hit the car on the way down, they bounce off like crazy. But if i manually move the car into the pillar, it does almost nothing.
It looks like that method applies velocity to the moving body, whereas currently perhaps it has no idea that the body is moving? Did I read that code right?
i have another related PG here: https://playground.babylonjs.com/#WF3VKZ#465
where the scenario is: soccer - having a character push an object around.
Did you try to set linear/angular velocity instead of setting position directly?
No b/c i need to sync players in a multi-player environment to make sure they’re in exactly the same place.
Here’s a better PG - i tried applying Force/Impulse on collide.
Not sure how to tell which instance the collision is happening on in order to applyForce to the correct instance…?
Although still the problem that can run through the object.