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

Using Motion Time as a transition condition.

Discussion in 'Animation' started by UltraRobot, Mar 10, 2022.

  1. UltraRobot

    UltraRobot

    Joined:
    Dec 6, 2019
    Posts:
    24
    I have a walking animation where the character makes really long strides, and I want to return to idle via a transition animation based on where in the animation phase the walk animation currently is. So that when if he stops walking with the right leg forward he plays a different transition animation idle than if he stops with the left leg forward.

    I see that the motiontime is in the animationstates, so I guess I could read it from the controller and then feed it back in to a custom variable via script and use that as a condition, but it seems very roundabout. Is there a way to use it directly within the animationcontroller?
     
  2. SethMeshko

    SethMeshko

    Joined:
    Sep 20, 2014
    Posts:
    109
    You can setup events in the animation clip itself. That event can be listened for and trigger whatever you like. Just look for animation events in the documentation. Note, there can be issues with events getting missed due to transition blending (if you are using mecanim). You could also use normalized time and just have a >= condition as the trigger too.
     
  3. UltraRobot

    UltraRobot

    Joined:
    Dec 6, 2019
    Posts:
    24
    Thanks. I checked it out, but decided not to go with events since they can be missed. I sampled the normalized time and directed it back into the Controller as a condition.