Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Mecanim the other way around?

Discussion in 'Animation' started by Slein, Oct 1, 2013.

  1. Slein

    Slein

    Joined:
    May 26, 2013
    Posts:
    9
    Hi there,

    So I've been using mecanim which makes your character move as fast as you did in maya, which obviously helps in preventing sliding.

    I was wondering if it is possible to make it work the other way around. So it makes the animation play faster or slower depending on how much the character's position changes? So make the objects movement dictate the animation, rather than the animation dictating the object's movement. As I do like to control the character through scripting.
     
  2. Slein

    Slein

    Joined:
    May 26, 2013
    Posts:
    9
    bump
     
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    9,777
    You can create a blend between two motion fields on the same animation clip, set with different speeds. In your script, you just change the float parameter that it blends upon. For the float parameter, use a value that represents how much the position needs to change.
     
  4. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    484
    Wouldn't making the animation play faster or slower also cause a change in the characters position(assuming root motion is used)?

    Perhaps you want the old legacy animation system where you play a simple animation and programmatically tell your character where and how fast to go regardless of the animation being played.
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    9,777
    That's exactly what the blend I suggested would do. It would blend somewhere between slow and fast versions of the clip.

    But, as jRocket suggests, perhaps you really want to remove root motion from your clips and control everything manually through the legacy system.