Search Unity

Mecanim : Driven Additive Sweeps

Discussion in 'Developer Preview Archive' started by DanTreble, Oct 24, 2012.

  1. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    In a previous life, to make a character aim a gun, we have used a couple of driven additive sweep animations, masked on their upper body.

    I can't see a way of driving an animation's playback position in Mecanim.

    To be a little more clear on exactly what we were doing, we would have a base run with gun animation. We would also have an additive sweep gun from left to right animation and an additive sweep gun from upper to lower. Then we would drive the play time of both the additive animations to make the character point the gun anywhere within the circle formed by the left/right up/down sweeps.

    This video shows the technique (jump to 40 seconds in)

     
  2. smb02dunnal

    smb02dunnal

    Joined:
    May 5, 2012
    Posts:
    439
    I too am interested in how this is possible with mecanim!!
     
  3. pierrepaul

    pierrepaul

    Unity Technologies

    Joined:
    Jun 19, 2012
    Posts:
    162
    Are you doing the sweeps using Fk animations or procedurally ? (sorry my audio is not working ATM, cant listen to video)

    What I would do :

    FK driven : use an additionnal layer, with an upper body mask, and set the layer weight accordingly

    Procedurally : Use the OnAnimatorIK callback to setup IK rig.

    Hope this helps!
     
  4. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    FK, our animators are used to authoring them this way.

    Have exactly that. The problem is the 'driven' part. There is no way to programatically scrub the play position of the additive animations in the current api. Unless I missed something?

    Thanks

    Dan
     
  5. samuelmorais

    samuelmorais

    Joined:
    Aug 3, 2012
    Posts:
    62
    @DanTreble,

    In Unity 4 beta 11 you have now the function animator.ForceNormalizedTime(float normalizedTime) so that you can set the exact normalized time of the current state or transition.
    Is it what you call "play position"?

    Regards,

    Sam
     
  6. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Thanks Sam, how do I target animator.ForceStateNormalizedTime at a specific layer?
     
  7. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Hmm, I didn't know that was public. :)

    That's actually a method that we used internally, but it was deemed safe to make public. It's in the process of being renamed to ForceStateNormalizedTime and it only works on the base layer!

    So you cannot do a horizontal and vertical sweep as the OP wants. But perhaps he can settle with either horizontal or vertical sweep and then use a blend tree for the other axis? Be advised that this functionality is likely to change in a later 4.x release. We do want to support driven additive sweeps in later releases but its just too late to add to 4.0.

    EDIT: I just tested it with additional layers and transitions to be entirely sure how everything works. You must call it every frame and if there is a transition in layer 0, both the old and new state time will be forced. The transition is completely unaffected by the forced time (except transitions using exit time because exit time needs to be exact match when time is forced). All other layers are completely unaffected.
     
    Last edited: Nov 1, 2012