# Setting position and look direction of a GameObject

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:

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?

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.
• @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 Apr 16 '18 at 21:26