Rotate hinge joint with angle

I’m trying to rotate the model objects with angles like robot arm, but arms doesn’t rotate in constraint to each other. I tried using HingeJoint but I think it does not support rotating with a specific angle https://playground.babylonjs.com/#AV3J28#12

Structural-diagram-of-four-DoF-robot-ARM

Welcome aboard!

I never used physics engine before, so take what I’m saying with a big grain of salt!

cc @Cedric who knows much more about physics than me and who will be able to shed some light on what’s going on (but be patient as it is vacation time these days).

First you have some existing rotations on your meshes, I’m not sure it’s the easiest to work with, so I have removed them in my PG below. Also, it seems physics don’t work as expected with parented meshes, so I have removed the parents for arm1 and arm2.

Also, I think you should not update the rotation / position properties “by hand” but should apply impulses instead when working with physic objects.

So, here’s a PG that appears to work when rotating just the second arm:

I could not make it work when trying to add another joint and rotating arm1, though…

I tried using some basic models and it is working just using child & parent
https://playground.babylonjs.com/#UFVU18#664
but I want try with glb file from blender. do you have idea how to export it correctly should should I make objects parent & child in blender or separate them??

You are not using a physics engine in this PG.

If you want to use a physics engine, I think we’ll have to wait for @Cedric’s feedback as I’m not competent enough in this area.

Did you try to use IK ? Bones and Skeletons | Babylon.js Documentation

I think it would match what you want to achieve: have something dynamic that you can play with while keeping it simple.