Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Did Unity 5 fix this age old problem yet?

Discussion in 'General Discussion' started by gsus725, Mar 4, 2015.

  1. gsus725

    gsus725

    Joined:
    Aug 23, 2010
    Posts:
    250
    Hi does anyone know if Unity 5 allows script access to individual animation state's speed variables in Mecanim?

    This is an age old problem with Mecanim that for some reason Unity still hasn't addressed even though they acknowledge it is a problem. No use in me downloading it if they haven't fixed that yet.

    Unity 5 is great in many ways but without this oh well for me

     
    Last edited: Mar 4, 2015
  2. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Check the docs is that AnimationState.Speed?
     
  3. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,381
    Uhh, all day long.
     
  4. Breyer

    Breyer

    Joined:
    Nov 10, 2012
    Posts:
    412
    as i know no direct support (coming in 5.x) but i think this might be hacked via custom StateMachineBehaviour script
     
  5. gsus725

    gsus725

    Joined:
    Aug 23, 2010
    Posts:
    250
    That is only for the legacy animation system unfortunately. It doesn't work for Mecanim
     
  6. CaoMengde777

    CaoMengde777

    Joined:
    Nov 5, 2013
    Posts:
    813
    oh wow thats pretty lame...

    .. i guess you could have like.. X number of "run" states, for each speed ? .. but thats kinda lame too, but itd work.. unless you have like 100 or something...

    thats kinda what i had done before.. but not exactly for this.. i had different animations

    sneakWalk
    walk
    run
    sprint


    but yeah.. like, path of exile, the character attack animation varies by "attack speed" character stat... which can be like 0.1 to well my character had like 17 attacks per second LOL, it looked ridiculous fast
     
  7. gsus725

    gsus725

    Joined:
    Aug 23, 2010
    Posts:
    250
    Yep looks like I'll have to make a giant tree of different speeds for each attack animation, it'll look something like this but with way more attacks. I'm going to end up having at least 20 of these, I was hoping for a better way in Mecanim

     
  8. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    Waaait a second... Can't you use Animator.speed?
     
  9. Breyer

    Breyer

    Joined:
    Nov 10, 2012
    Posts:
    412
    You could but this is global... as i said i think you could use StateMachineBehaviour and query which state is playing OnUpdate and and change global speed based on this query... not so convenient but i think better than bazillion animations...
     
  10. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You could use a script to do this within mecanim (nodes can have scripts now).
     
  11. gsus725

    gsus725

    Joined:
    Aug 23, 2010
    Posts:
    250
    StateMachineBehaviour? I just now read the script documentation for it and I don't see how it could be used to alter the state's speed, could either of you provide a few more hints? Thanks

    I could of course use it to change Animator.speed but that would still interfere with the speed of other layers and animations that are playing simultaneously.
     
    Last edited: Mar 5, 2015