Search Unity

Best way to make character animation with timeline?

Discussion in 'Timeline' started by John_Leorid, Jan 27, 2021.

  1. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    651
    Hi,

    Unity has expanded on Film, so there must be a good way to get good looking character animation with correct foot placement, grabbing things, looking at things during the animation and most important: controlling the position of the character with good animation flow.

    Currently we are working on some cutscenes in our game, pretty simple stuff, just a character running to a fixed position, stopping, rotating to face the player behind a glass window, then talking and running away again.

    Our approach was to remove root motion from all animations and just animate the transform position of the character and then manually trying to match foot-placement by adjusting the duration of the translation.
    Seems impossible to get it looking realistic this way.

    Normal Mecanim Animator IK, atleast for LookAt seems to not work at all. Theres animation rigging, which has more functionality and more setup cost (it takes longer to get it working) but even when using this one, it's only half the solution.
    Maybe, haven't tried yet, Animation Rigging will help with the LookAt-Problem but the movement and Foot placement?
    In this sequence the character runns for about 5 seconds - taking probably 50 Steps, I can't adjust the foot position manually for all 50 steps?

    When using root motion, theres the problem, that the duration of the animation determines the distance - so it's quite hard adjusting things. If I move him one step less at the very first animation, so he stands half a meter futher left, it would break every animation after this one as with root motion, they all depend on each other and their previous ending positions.

    So what is the right approach to get those characters to move more naturally without having each animation depend on the end position of the previous one and without manually adjusting foot placement for 50 individual steps?
     
  2. gekidoslayer

    gekidoslayer

    Unity Technologies

    Joined:
    Sep 27, 2016
    Posts:
    134
    the simplest is to use root motion - this would be what most film / animation projects do. Trying to match via hand keying world positions or using IK just isn't feasible. This of course requires that you animate your cutscenes (or use mocap or whatnot).
     
  3. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    651
    Would Kinematica work in this case?
    https://docs.unity3d.com/Manual/com.unity.kinematica.html
    Do you know what's the state of this technology right now and if it would be feasable for cutscene movement?
     
  4. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    If you were animating in other software it would be a similar process to animation rigging. It performs very smoothly because (unlike most IK) it doesn't need a late update workaround to adjust the pose after reading the anim. Instead it adjusts the anim before the figure is posed.

    There is a bit of set up, but it seems more convoluted than it really is – in a 'normal' 3D package this animation rigging would be specialty tools and panels. Unity has designed it to be gameobjects and components – some nested as child objects and some linked by script. It's confusing at first because it can feel arbitrary and unfocused… but, once you grasp the basics and the necessary components, it's dead-easy to work with: essentially positioning gameobjects.

    Because they did it the Unity way, with gameobjects and components, it integrates with everything – there are gizmos in the scene to physically adjust, and any script or physics that can move a gameobject can take over your rig (hands, elbows, hip, knees, feet, and of course head, eyes, fingers…tails...) It's tools you already know. Once you are over the hump it goes very fast.
     
  5. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    651
    I've used it in the past, just never in combination with timeline. ^^
    The setup is still quite more complicated than literally two lines of code:

    Code (CSharp):
    1. animator.SetLookAtWeight(templookWeight, tempbodyWeight,
    2.                 tempheadWeight, 0, tempclampWeight);
    3. animator.SetLookAtPosition(target.position);
    Which I use to get my enemies pointing their gun and head towards the player. (temporary weights because of some interpolation between Idle (weight 0) and Aiming (weight 1))

    You can do much more stuff with Animation Rigging but setting up targets and hints for 2 Bone IK .. manually dragging and dropping the correct bones into place ... theres room for improvement. ^^
    And maybe the will improve it, it's still in Preview.

    Still - Animation Rigging won't help with the movement, so I guess I will setup some kind of path or use the navmesh (like I guess many games do it) and use root motion to drive the NavMeshAgent (with the same script I just wrote for my enemies - now their movement looks much better ... well, most of the time xD ) or the Objekt on a spline.

    I just read that you can set the speed of the navMeshAgent to a small value, like 0.1f and then drive it with the root motion and yes, this seems to be the best approach, even in cutscenes.
     
  6. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,793
    But if you use root motion you can’t really place your characters in the scene, since if you want to place your humanoid character at a certain position in the scene, you can’t really, since that position is multiplied by the human scale factor, which results in a super confusing (and glitchy), workflow.
     
  7. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,793
    Also, Animation rigging is kinda too fussy to set up and its baking tools don’t support humanoids for some reason.

    Kinematica is temporarily (?) abandoned, so don’t count on that either.
     
  8. wetcircuit

    wetcircuit

    Joined:
    Jul 17, 2012
    Posts:
    1,409
    I don't see how '2 lines of code' is a useful metric, especially when it's apples/oranges on their capability.
    Is '2 lines of code' a limitation on your entire project or just this one area? :rolleyes:

    You are stuck in a box that 'a script must do this', so you haven't learned a single thing from my reply, or why I recommend that you look a little deeper into the tools that are available. Sawing a board in two seems awfully complicated when you only use a hammer.

    good luck.
     
    Last edited: Jan 27, 2021
  9. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    651
    Two lines of code to make it work with any character with no other setup cost is quite efficient.
    Dragging and dropping bones from a skeleton is just more time consuming - linear to the amount of characters.
    Sure you can make the whole rig a prefab and add it to another character, but you have to assign the bones manually, with a complicated rig this not only can lead to errors but also costs time which we don't have right now.

    Changing the prefab (where all constraints of the Animation Rigging are placed) also means changing it on every single character that uses this prefab for IK.

    Injecting the correct bones automatically to the AnimationRigging components is not quite straight forward.

    Sure if we were a team of 20 devs, having some Animaton Artists who set it up for each character, it would be my first choice but we are just 3 devs and we have lots of other things to do, so automation, maintainability and keeping things uniform across the whole project is vital in order to meet our deadlines.

    To answer your question: "Is X lines of code a "limitation" on your entire project?" more or less, yes, because of time constraints.