Root mesh with skeleton: keep center of rotation of root mesh irrespective of bone positions

Hi

Please have a look at this playground: https://playground.babylonjs.com/#J62R3F#99

See line 27:

rootBoneTF.position.x += 2;

Can I set the bone’s position offset (and have it rendered at the position) but the rotation as if line 27 was commented (rotate “in place”)?

I tried using pivots but with no success. I cannot use an extra TransformNode. I need the position offset on the bone.

Best wishes
Joe

I am not sure to understand the use case :frowning:

In this case why not offsetting the root mesh instead of the root bone ?

The root mesh position and rotation properties are the source of truth for actor/object position and rotation all over my code base. Up until recently no problem.

However, recently I needed to solve an issue where actors needed to move from tile center to tile edge. For instance, when standing on a tile, an actor can go into cover by pushing its back against the covering wall. This requires that I move the actor slightly in the direction of the cover so that its back touches the wall. Since the distance to each covering obstacle is dynamic I cannot encode this in the animation.

If I use the root mesh position, it breaks my tile logic all over the place.

As an alternative I added a TransformNode after the root mesh. So I would use this “SubTileNode” for position offsets. But unfortunately all meshes attached to the root mesh, or rather its bones, (via mesh.attachToBone) remained unaffected.

This is how I ended up adding a new root bone. And it does work nicely - as long as I do not rotate :frowning:

I think the only way unfortunately is to add an extra node in your hierarchy :frowning: or revisit your tiling logic.

1 Like

Aww, bummer. Oh well, at least it is nothing unsolvable :slight_smile: Thanks for your feedback, sebavan!

1 Like

Ha! Easy peasy with TransformNode: there is a second parameter in mesh.attachToBone :face_with_monocle:

N.B. Dont forget to reset the new TransformNode after parenting.

edit:

P.S. Except it does not rotate correctly either… lol easy peasy my