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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Directly transition from walking fwd to bwds without entering idle first [FIXED]

Discussion in 'Animation' started by sasa_dev, Apr 10, 2020.

  1. sasa_dev

    sasa_dev

    Joined:
    Apr 4, 2020
    Posts:
    10
    Hello fellow game developers

    I'm creating animation states for my third person character. Since it's getting complex when only using motion fields, I decided to use blend tree's or sub states for my walking animations. Otherwise this wouldn't be a problem for me.

    Problem:
    When the user directly switches from W to S (forward to backwards) the animator transitions it first into the idle state. How can I get it to transition directly? I tried 3 methods but I just can't get it done..

    upload_2020-4-10_12-39-32.png

    First I made this blend tree including the idle motion. While testing I noticed the problem. I decided to delete the idle motion in the blend tree and put it on the base layer as the entry state. Then I made a transition from idle state to this blend tree which first worked perfectly testing. But when I added the transition from this blend tree to idle and started the game, the problem occured again. Afterwards I tried a sub state machine, worked perfectly too before I added the transition back to the idle state..

    So how can I make it go from walking forward to backward directly without it transitioning into the idle mode when you're not standing still?
     
  2. sasa_dev

    sasa_dev

    Joined:
    Apr 4, 2020
    Posts:
    10
    For now I made an idle time which sets the bool to true in the transition back to the idle motion when over 0.2f. However going back to the idle state comes with delay. So if someone knows a better way please: "can u show mi da way?"
     
  3. sasa_dev

    sasa_dev

    Joined:
    Apr 4, 2020
    Posts:
    10
    SOLUTION:
    So I had the same problem for the sides and for fixing it I used these parameters to smooth out the axis values, now my movement is perfectly satisfying. Awesome!

    animator.SetFloat("horizontal", inputX, 1f, Time.deltaTime * 10f);
    animator.SetFloat("vertical", inputZ, 1f, Time.deltaTime * 10f);