I’m working with a mesh that has both physics enabled and an animation. I noticed that when the animation starts, the mesh moves visually as expected, but the physics body stays in its original position and does not follow the animation.
It seems like the physics shape is not updating along with the animation.
How can I make the physics body follow the mesh animation correctly
I imported a .glb file that includes some meshes, such as a door, with an opening animation.
I added a PhysicsAggregate to the door, but when the animation starts playing, the physics body doesn’t move with it.
const mesh= await ImportMeshAsync("models/environment/mesh.glb").then(res => {
res?.meshes?.forEach(m => {
if (m.getTotalVertices() > 0) {
const landPhysics = new PhysicsAggregate(
m,
PhysicsShapeType.CONVEX_HULL,
{
mass: 0,
},
);
}
})
return res
})
A body with a mass of 0 will be static and is expected to not move.
It’s possible to switch to Animated mode and control the body position/orientation. Check this doc page for the different motion types and preStep : Babylon.js docs