Search Unity

Physics Animation interfering with LateUpdate animation modification loop

Discussion in 'Animation' started by Void24, Oct 27, 2015.

  1. Void24

    Void24

    Joined:
    Oct 15, 2013
    Posts:
    50
    My characters need to have spine corrections done after animating due to the fact that the Unity Humanoid system has no concept of decent upperbody/lowerbody animation workflows. You either get hip movement and shoulders wobbling everywhere, or no hip movement. This is unacceptable.

    I created a fix by correcting missing spine segment animations after animations were computed in LateUpdate.

    Unfortunately, I also need to compute these animations in FixedUpdate using Physics Animation mode as opposed to Update. This is due to low frame rates causing inconsistencies in weapon arcs.

    The problem is now that I can't seem to get my spine corrections in place before they are needed in scripts, but after the animations are calculated.

    I think I need a LateFixedUpdate function.

    Any ideas would be greatly appreciated. Also Unity could just remove the hip bone from the upper body in Humanoid, but I think that ship has sailed. :(
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Or you could author it for Unity. Or you could use Generic. In our use of it, we found it was 10 out of 10 times our fault for not considering the target being a game engine... it's pretty normal and I don't think it would be unity's responsibility.

    As for hip/shoulders wobbling, anything like that we've just found it's our fault. What is your workflow and what do you do? Probably a far better idea of fixing it to begin with rather than relying on band aid code.

    Or: http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnAnimatorMove.html
     
    theANMATOR2b likes this.
  3. Void24

    Void24

    Joined:
    Oct 15, 2013
    Posts:
    50
    I am certainly not claiming that my understanding of what I have to work with is perfect, I would love to learn that it is just a mistake on my part. That would indicate an easy fix :)

    As an example from my project, take running and swinging a sword. These are my attempts so far:

    -----
    upper body animation layer with mask that excludes body - Lost shoulder movement in swings. Major loss of animation control.

    upper body animation layer with mask that includes body - Overrides hip movement in lower body animation, run animations without hip movement are not acceptable.

    upper body animation using additive blend - Actually works a bit, until you have to work around a disaster of a decision that is (Every animation uses its first frame as a zero state instead of using a T pose or a preset zero state).

    upper body animation layer with mask that excludes body, combined with a post-animation pass that corrects shoulder rotation based on a duplicated chest joint - Fixes the issues for me. Which leaves me at my first question.
    -----

    I would love to hear a separated upper/lower body animation workflow that both incorporates hip movement into run cycles, and shoulder movement into upper body actions. Please let me know if there is a clean way to do this.

    OnAnimatorMove should be a great fix if it triggers on the FixedUpdate cycle when using physics animation. I will give it a go today. Thank you!
     
  4. Void24

    Void24

    Joined:
    Oct 15, 2013
    Posts:
    50
    UPDATE:

    So I tried OnAnimatorMove and OnAnimatorIK, and while both allow me to make changes, they do not show up in the rendered scene. Unity is doing something more complex with the physics animation option..

    So far, I have had luck just running my spine fixes on FixedUpdate, and using the resulting transforms to make raycasts and generate geometry for trails.

    Unfortunately, the LateUpdate is STILL REQUIRED for some reason.. Like it does ANOTHER animation transform update for the render.. I am guessing to interpolate?

    The problem here, is that if I fix the spine AGAIN, it messes up the next physics update, as it seems to be cached somehow, or just does not update after a frame update. It is honestly pretty frustrating how undocumented it is.

    My best bet it seems is to cache the fixed spine transforms so I can perform them any number of times non-destructively. You sure are right though, a method of using animation data from the FixedUpdate loop that is supported by the engine would be awesome.