I have imported a mesh from a babylon repository, but when I try to rotate over the Y axis, it simply doesn’t work. I’ve looked up the docs but can’t find anything significant.
const result = await SceneLoader.ImportMeshAsync("", "https://assets.babylonjs.com/meshes/", "HVGirl.glb", scene);
const player = result.meshes[0];
player.position.y = 2;
player.scaling.scaleInPlace(0.1);
const shapeCapsule = new PhysicsShapeCapsule(
new Vector3(0, 2, 0),
new Vector3(0, 0.35, 0),
0.35,
scene
);
const aggregate = new PhysicsAggregate(player, shapeCapsule, { mass: 1, restitution: 0 }, scene);
aggregate.body.disablePreStep = false;
player.rotation.y = Math.PI / 3 // not working
Bonus question:
I was unable to do PhysicsAggregate(player, PhysicsShapeType.CONVEX_HULL... its complaining. Is it because I’m targeting a root node and not the children?
So far I find out, you should first set the position of the mesh then create the aggregate. If you need to move the mesh later again, you have to dispose and recreate the aggregate after movement.
I think result.meshes[0] might be the parent transform of the mesh you are interested in. You should check for result.meshes[1]
Please provide a PG so we can more easily test.
Can you explain why setting the roration Y value directly is not working after applying physics to a mesh?
What is the difference between .rotation and .rotationQuaternion?
Physics uses quaternion. so once an object is physicalized, you’ll have to use the quaternion instead of Euler rotation.
You can create the Aggregate that way but you’ll have to specify a mesh used to compute the convex_hull with. So it would look like: