Search Unity

Question Questions about getting animations from Blender into Unity

Discussion in 'Asset Importing & Exporting' started by Poi-son, Jan 22, 2022.

  1. Poi-son

    Poi-son

    Joined:
    Dec 22, 2021
    Posts:
    33
    Hi,

    Actually, it might be more appropriate to ask some of these questions under Animation sub-forum but since Blender as an external tool is involved and I have some non-animation related questions, I decided to ask them here.

    I'm working on my 3D character in Blender 2.93.5 and creating his animations within Action Editor and then exporting it as a whole in FBX format to later import in Unity.

    However, since I'm quite of a newbie, I have some misunderstanding or missing concepts within animation world. :oops:

    1) FPS. I can see that it stands for Frames Per Second. But how does it really translate in the real-world and between Blender and Unity? I mean, i.e. I prepare my run animation which consists of 24 frames in Blender choosing 30 FPS within render properties. I import it in Unity and see that it "kind of" skips some frames or not as smooth as how I dream it to be. My game in Unity environment currently runs around 140 FPS. So I assume it is not about performance hits.

    Then, how to make animations smoother? Should I span my whole same run animation to, say, 48 frames or even go crazy and 96 frames in Blender and making sure the bone rotations and everything in-between keyframes capture the little-most details? So, how do you really target an FPS for smoother animations? Because obviously the FPS the game currently runs in isn't taken into account (unless it drops dramatically around 14-15 FPS passing minimum of 30 FPS) and curves play a higher role, how do you determine an acceptable FPS value and target it when animating a character?

    In short, what is the key factor that determines the smoothness of animations other than runtime performance?

    2) When I'm about to add another animation for my current character, I export it again to FBX with the same name and copy paste it in explorer overwriting the existing FBX so that I would only bring in the new animation into unity by clicking the "+" icon in the animation tab of imported model. Is this the most convenient and comfortable way of doing it to add new animations or update existing ones?

    3) Attaching armors etc. How to do it? I have absolutely no idea how to accomplish this in the proper way. i.e. Should I prepare all my animations with a second variation with armors and than lay them down in another layer within animator component and switch the layer weights upon grabbing an armor?

    OR

    should I only create my armor within Blender and assign several bones to it then toggle those bones on and off in Unity in runtime? If so, how to deal with textures?

    OR

    ANIMATION RETARGETING is the definitive answer and should I look for tutorials on this?

    4) Applying root motion or Root transform Position (Bake into pose). While doing some animation tests within blender, it is really hard to capture the look and feel of some animations without actually seeing them in place. i.e. Jump animation. Since I manipulate my in game characters Y motion from the script, I choose to create jump animation "in place" without actually manipulating Z-axis location of the model within Blender. But this makes it difficult for me to preview the jump animation and figure out how it will translate into action in Unity. Is playing around with Root Transform Position(Bake into pose) per animation clip key to my problem?

    Thank you all and I appreciate any tips or help on these subjects! :)
     
  2. Poi-son

    Poi-son

    Joined:
    Dec 22, 2021
    Posts:
    33
    OK,

    Since there are bunch of views with no answers I think I asked for too much in a single post and decided to narrow down and simplify my help requests and also provide my findings since then.

    1) FPS thing : When I increased my run animation cycle from 24 frames to something around 80 frames, it felt smoother.
    My question though is still valid : Is the number of total frames for an animation completely dependent to the FPS the game runs in? How do you decide how much frames is enough for any given animation?

    2) I'm still following that workflow atm and I'm currently fine with that until I find anything controversial about it.

    3) OK, about attaching several armor pieces, I tried 2 different approaches. I created duplicate of my character in Blender with armors on him and then exported it as another FBX into Unity. Then, when he grabbed the armor, I swapped whole mesh. While this looks to be working ok, I believe this is the "lazy version" of doing it.
    because,
    a) Swapping whole character for some little armor changes doesn't look resource friendly to me (totally guessing, no expert)
    b) If I have the need of having modular armors, or armor combinations, this would not work.

    So, for a second method, I exported all different armor pieces as FBXs and imported them into unity.

    While 2nd method seems more modular and the way to go, this brought other questions onto the table.

    - When I export armor pieces, they are exported with animations baked onto them. So I do not need to parent them to the character in runtime. But, I don't think this would be the nicest way of doing it because it is double or the triple work if any of the animations are updated. Plus, it is out of logic to have animations baked within an armor piece.

    So I just left baking animations options out when exporting armor pieces. This brought me to the conclusion that I need to be able to attach each armor piece to its corresponding bone in runtime. After several trials and errors, I made it to work in edit mode and when I tested it in play mode, all armor pieces move with the corresponding body parts.
    But, it looks to me a bit tedious to try to attach a i.e. glove to 6-7 levels deep hand bone

    Anyway, to make it short, how do you create, import and dynamically attach or remove armor pieces in runtime? I tried to find tutorial videos on this without much success. Would be glad to hear about the approach of experienced users.

    Thank you,
     
  3. I highly recommend to use UMA 2 on the asset store and on github. It is a community free asset made to create things with mesh and texture slots and be replaceable runtime. One of the main purpose of this is exchangeable clothing and armor in runtime (but you can use it for building cars, planes, buildings with replaceable parts too).
     
    Last edited by a moderator: Jan 29, 2022
    Poi-son likes this.
  4. Poi-son

    Poi-son

    Joined:
    Dec 22, 2021
    Posts:
    33
    Thank you for the recommendation. I generally try to learn how to build things from scratch on my own and a bit afraid of depending on the 3rd party tools but I'll check this one out.

    Actually I thought of creating permanent "slots" attached to specific body parts that would act like containers to be parented for armor pieces in runtime.

    I better check UMA 2 to see how it works.

    Thanks again!