Making a bone pointing to an object

Hello BJS community,

I’m trying to do a sort of elastic band (i don’t want the diameter to reduce while stretched). So it’s quite like a “straight infinity rope” going from it’s origin to a distant object pulling it. It could be pulled on any direction.
The simple way to do that could be to make the rope’s bone pointing and stretching toward the object.
I have found a function in order to make a bone pointing toward an object, but not stretching. As the distance between the rope origin and the moving object won’t be fix, it needs to stretch…

Any idea about how i could do that ?

Hey @Thibaut,

You might want to look into a combination of bone scaling and BoneIKControllers.

https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#scaling

https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller

Thank you @PirateJC for your answer (and for your awesome videos on youtube)

Ok, thank you, so i just need to use BABYLON.Vector3.Distance(object1,object2), and use that value to stretch on the Z local axis !
Thank you very much !

1 Like

Close to IK, but there’s an actual look controller. Probably on the same links as @PirateJC posted. The code seems very computationally expensive. You might not want to leave it updating afterwards.

1 Like

@JCPalmer Oh this CPU or GPU expensive ? I did not assumed this. I do not understand “You might not want to leave it updating afterwards.” The user will choose a position and than the rope will be pulled. How could i not leave it updating ?

A way to do it, that could be possible, but not “sexy” is simply by parametric shapes using lines. But i found them too thin for the purpose of my project. As it’s not a game but a project with an educational purpose it could fit the needs. Is there a way to make them look thicker ?