Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

[REGRESSION] mecanim no longer allows to show animation at time t

Discussion in '5.5 Beta' started by laurentlavigne, Nov 21, 2016.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    Legacy used to allow for animationstateinfo.normalizedTime = f
    For some reason mecanim animatorstateinfo.normalizedTime is read only so we can't show animation at time t!

    EDIT: it's called animator.playbacktime... which doesn't work.
    Reading the (god awful) doc on animator, there seem to be a difference between playback lower case and Playback upper case. Where playback is normal playback of a clip and Playback is something related to recording animation live.

    So what is the new and (un)improved way to do normalizedTime in mecanim? Or better yet: FIX THIS and make is read/write. pretty please with sugar on top.
     
    Last edited: Nov 21, 2016
    MrEsquire likes this.
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    If you want to change the current time of the current played state you need to use
    Animator.Play(0, layerIndex, myNormalizedTime);
     
  3. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    In the Animation component, all "states" are / can be active at the same time, so the normalized time is persistent, and writeable.

    In the Animator Component, only one state can be active at a time (for a specific layer), so the normalized time in the state info is not persistent, and can't be changed directly. You need to use a method (Play or crossfade) to change it (because it has side effects that don't exist in the Animation Component.
     
  4. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    I am also using StartPlayback before calling play. Is this the correct way if you want to play the animation manually?
    I wouldn't want to run into compatibility problems in the future for this as I am relying heavily on this feature(need fine grained real time control over playback speed).
     
  5. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
  6. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    Can't remember what was the issue exactly but I remember seeing animation glitches due to the fact that Play without StartPlayback automatically play the next frame and probably do some other things automatically. In some cases like when playing an animation backwards it is leading to some glitches(probably something in mecanim gets updated after lateupdate).
    Don't know if it was a bug or something unavoidable due to the way mecanim works.
    In my game I switch between the mecanim state machine to my manual playback, is it supposed to be always working regardless of any state,transition or whatever if I don't use Startplayback()? Keep in mind I do things like playing forward, backward and playing the same frame.