I found a few workarounds but they don’t seem to be optimal:
a) Mark bone as dirty on every step of the character
b) Move character with skeleton
My questions:
What is the recommended approach to attach mesh to a bone without animation?
When I want to move a character, should I move its mesh or skeleton? The popular lib I use, CharacterController moves it by character, I would have to rewrite it to move its skeleton.
I think I am misunderstanding the parent relationship here, when I move the character, shouldn’t the skeleton move, then the bone, then the attached object?
Similar topic WITH animation:
This one breaks down as soon as you comment out the animation out on line 48, see it here:
www.babylonjs-playground .com/#11BH6Z#717
(new users can’t post more than two links)
For performance reason, the system tries to never update something that is cached so flagging the bone as dirty to force that update is a god technique
Moving the mesh should work ;I’m on my phone so I did not check your pg) as long as you are not loading your data from a gltf. If this is the case then you need to figure out which mesh is the skeleton impostor (this is a bit weird to me but gltf will delegate the skeleton animation to a mesh hierarchy).
3.Moving the mesh will only update the mesh world matrix so the system will not need to update the bones (they are all local matrices) so it will update the rendering (gpu will recompute all the matrix multiplications) but no change to the bones on the cpu side)
Thanks for checking up. I ended up flagging the bone as dirty in every code path that moves the character.
Although it still feels like it’s not really attached in the same sense, since the attached bones move when the character moves but the mesh attached to the bone doesn’t. Also in future I need to remember to flag a specific bone as dirty if I try to move the character in different ways, or wrap the logic around some extra class.
I don’t know much about the Babylon internals, it just felt like I was probably doing something wrong.