Hello everyone. I’ve probably studied the entire forum in
For several weeks, but I still can’t figure out how to add physics (havok) to a glb/gltf object that has animation, if bones. I downloaded the object itself and imported it into babylonjs, to my own misfortune. the problem is this - when trying to set physics for each mesh of an object, the object falls apart into pieces. I am a newbie in programming, there is a great desire to write a small and simple game. help solve this problem)
here is this object in the sandbox.
BABYLON.SceneLoader.ImportMeshAsync(‘’, ‘’, “Ninja_Sand.gltf”, scene)
.then((result) => {
const root = result.meshes[0];
const meshMass = 80;
root.position = new BABYLON.Vector3(0, 0, -12);
const meshShape = new BABYLON.PhysicsShapeMesh(
root,
scene
);
const meshBody = new BABYLON.PhysicsBody(
root,
BABYLON.PhysicsMotionType.DYNAMIC,
false,
scene
);
meshShape.material = {
friction: 0,
restitution: 0
}
meshBody.shape = meshShape;
meshBody.setMassProperties({ mass: meshMass });
});
tried different options, and const root = result.meshes[1]; and each mesh. now the object falls through the ground. maybe this problem is due to the presence of bones in the object? how to solve the problem, how to make the object function as it should?
does anyone know?
cc @Cedric
that being said, please repro inside the playground so we can help / fix issues
To load external assets: Using External Assets In the Playground | Babylon.js Documentation
I’ll try to make a playground, for this I need to upload this gltf object to an external resource so that there is a URL. Thanks for answering, I thought that no one sees my topic))
I’ll second @Deltakosh asking for a PG but I think you are missing the joints creation between bone physics representation.
Did you see this doc page ? Babylon.js docs
Hello, here is my PG:
regdoll also used, so it can collide with a sphere, but with another gltf object it does not collide, but passes through it. I’m missing something, tell me what. I want to figure out once and for all how to correctly add physics (havok) gltf/glb to objects, those with bones and those without, because my second object is a basketball hoop, I also think I added physics incorrectly.
Thank you so much for helping!!!)
There are a few things to fix:
- no need to set a mass to static bodies
- There is no constraints defined
- try to avoid mixing old collision system with
moveWithCollisions
and Physics V2 - Check ragdoll limitations : Babylon.js docs
I’d suggest to start smaller with just 1 gltf and static bodies and iterate/improve after. Don’t be afraid of starting small.
constraints of bones specifically? if so, then this is not in ‘const config’ from my PG?
I don’t understand at all what Right Handed and Left Handed are. What is it and what is it for?
A quick search led me to this page :
You can find other pages and explanation if this one doesn’t work for you.
It’s an important concept in 3D.
tl;dr To make our dev lives miserable
thanks for the answer! while you are online, please tell me, should constrains be done for bone or for Body_primitiveX, as in my case?
constraints are between bodies
Poor unreal alone in his box
We are team Unity
historically, I picked that one because my first engine (Nova) was running on DirectX 9 which is left handed Y up…
Hello! I’m already losing hope of achieving a result, please help) here’s PG, I can’t understand why there is no collision between imported models (gltf/glb), when applying ragdoll to an object, as I understand it, physics is added to this object, but it collides with another object (ball). The ball collides with all objects. If ragdoll is set to position.y = 2, it does not fall, like a ball, for example, because ragdoll has physics and mass.
For unknown reasons I didn’t see last message. Sorry for that.
A quick look at the PG shows that the ragdoll is not made of dynamic bodies.
Bodies can be static, kinematic (controled externally but collides with dynamic bodies) and dynamic (fully controlled by physics engine).
The ragdoll PGs you can find in the documentation set the bodies as kinematic until they are switched to dynamic.
@Cedric
thank you! I have a question about constraints, should I create a new topic for this or here?
You can continue the thread here with new question.