Oct 20, 2015

Tutorial - How to export stretchy bones from 3ds max to unity

Stretchy bones used to squash this chubby low-poly frog named Arnold
from our free android game JuJu Frog made in Unity

In this quick tutorial I will show you how to set up 3ds max stretchy bones (with squash and stretch) and properly export them to Unity game editor.


Setting up stretchy bones in 3ds max:


  1. Start by making a simple bone and a nub bone chain
  2. Create two point helpers and align their position to each bone (alt + a keyboard shortcut)
  3. Open Animation > "Bone tools" dialogue and scroll down to the bottom. Select the main bone and turn off "Freeze Length", turn on "Squash" and press the "Reset Stretch" button
  4. Position constrain the main bone to the first point helper. Animation > Constraints > Position Constraint and click the first point helper
  5. Add "Look At" constraint to the main bone. With the main bone still selected go to Animation > Constraints > LookAt Constraint and click the second point helper.
  6. Position constrain the nub bone to the second point helper. Select the nub bone and go to Animation > Constraints > Position Constraint and click the second point helper

Now you have a fully functional stretchy bone setup in 3ds max. It will not work in Unity yet because squash property of the bone is not supported. We need to convert this information to simple scale transform readable by Unity.


Preparing bones for Unity

  1. Create another bone (let's call it bone_unity) and align it to the main bone. Position and orientation constrain the bone_unity to the main bone. I gave it red color so it is more visible.
  2. With the bone_unity still selected, go to Motion Panel, and assign "Scale Script" controller. 
  3. The Script Controller window will pop up. In it, create a new variable boneMax and click Assign Node. Navigate to the main bone and select it.
  4. Now paste this into the Expression text field: 
[boneMax.stretchTM[1][1], boneMax.stretchTM[2][2], boneMax.stretchTM[3][3]]



That's it. Close the Script Controller window and you have your bone_unity matching the squash and stretch of the main bone. It is ready for export! Just export the unity_bone and your mesh, no need to export the main bone and the nub. Also, make sure you select "Bake animation" in FBX export dialogue.

Hope you liked this tutorial. If you have some questions, please share in the comments or contact me directly via e-mail.

35 comments:

  1. Hi, I seem to be having an issue and wanted to know to which of the bones should I skin the geometry, to the main bone or the unity bone?

    ReplyDelete
  2. Never mind, decided to try both ways and its the unity bone you should skin to. Thanks for this, it was driving me crazy that I could make strechy bones work on unity. Keep up the good work! :)

    ReplyDelete
    Replies
    1. Hey man, thanks, I'm glad the tutorial was helpful! :)

      Delete
    2. thanks, Alonso if I don´t read your answer I wouldn´t think in that posibility of skin the bone_unity to my mesh :D, creo que hablas español así que, muchas gracias.

      Delete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. Thanks very much Ivan I was looking for squash and stretch in unity.

    ReplyDelete
  6. is this gonna work with multiple bones that are connected?

    ReplyDelete
    Replies
    1. Yes it works, just do the setup for each bone and you're ready to go.

      Delete
  7. Hi! I found your tutorial suuper helpful! I tried with one bone and it worked completely fine, but I'm having issues with a chain of, let's say, three bones. If I do the chain of three independent bones only attached to each other by constraint, they don't stretch; and if I do a chain with them in hierarchy, I cannot use the script for the unitybones because it doesn't get the scale of a bone that is child of another bone. Am I just absolutely clueless? Or did I miss something?

    Thank you for your time! :)

    ReplyDelete
  8. Aj hum ko Online Istikhara service ma Khush amdid karta hain. Ap har kisam k ma masla ko humse share kijiya or mann ki murad paya inshallah tamam bigrey huway kam darust ho jain ga. 1 phone call kar +923244544864, +6281315996474 apni taman pershani ka hall paya.
    Rohani Zaicha
    Istikhara
    Horoscope
    Astrology
    Istikhara for Marriage
    ROhaniilaj
    ROhani Wazaif
    Amil Online
    Amliyat
    Black Magic ka tor
    Marriage problem
    Husband Wife Problem

    ReplyDelete
  9. Hey, thanks for the tutorial. I was too lazy to do it by hand, so i wrote a handy max script that does it automatically. On top of that it automatically re-skins the mesh to those new bones, keeping all the weights consistant. Here it is:

    https://www.scriptspot.com/3ds-max/scripts/stretchy-bones-converter

    Can you post this link somewhere in the article please? I think it would be handy for all the people coming here.

    ReplyDelete
  10. Hello, can you come to a video tutorial?

    ReplyDelete
  11. Dude you are a life saver thanks so much.

    ReplyDelete
  12. This blog is very powerful. Its helps me a lot about this topic. very nice and the very
    helpful blog commenting Sites List that you have posted. I like it very much please keep
    doing this amazing work. Have a very nice day sir.: Hati Yang Dikhianati

    ReplyDelete
  13. Thank You and that i have a super proposal: How Much Home Renovation Cost average remodel cost

    ReplyDelete

Leave a comment here.