I'm making a bendable game object comprised of a number of bones. The bones positions are calculated using some joints and some maths and that is all working as expected. But I am struggling to rotate the bones to face the correct direction. I'm settings the bones positions like:

for ( int i = 0; i <= bonesCount; i++ ){
    Vector3 newPosition = someFunction();
    bones[i].transform.position = newPosition;

And that works correctly:


But when the bendable object bends the bones retain their original rotation:

enter image description here

I thought I could use Transform.LookAt on the bone at position i to look at the bone at position i + 1 but this gives strange results:


It seems like it's an issue with using the wrong axis (up, right or forward). I see Transform.LookAt accepts a second argument for worldUp but I haven't figured out how that works.

Any suggestions? Is Transform.LookAt the correct method to be using?


It seems like the everything is working, except that the bones are made in such a way that the forward axis is not the one you'd expect, so that they don't "look at" each other.

A very lazy solution would be, after you execute LookAt, on the same object, make a Rotate of 90 degrees. It's probably going to be on the X axis, but it depends how your scene is laid out.

  • \$\begingroup\$ Thanks, the very lazy solution works. I'll look at fixing the bones \$\endgroup\$
    – eskimo
    Apr 16 '18 at 21:21
  • 1
    \$\begingroup\$ @eskimo just a tip, if you import them as meshes from another program, you can rotate the object in that program and export them again, this should fix the issue without the Rotate \$\endgroup\$
    – TomTsagk
    Apr 16 '18 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.