Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Strafing animation breaks to play Idle

Discussion in 'Animation' started by JohnPet, Aug 11, 2015.

  1. JohnPet

    JohnPet

    Joined:
    Aug 19, 2012
    Posts:
    85
    I have a simple character controller (third person) using FPSWalkerEnhanced script from Unity wikify. I created a simple 2D Freeform Cartesian blend tree.

    Now, whenever I move up, down, left or right, everything animates properly, BUT if i move to the negative direction of one of the above (up, down, left or right) , the animation stops to play Idle and then continues to the moving animation.

    The blend tree is connected to the Idle motion with a Speed condition (greater or less than 0.1) and no Exit Times.

    What do you think is the problem? I need the animations to play smoothly and instantly (continue the blend tree animation) once input is pressed and not to first play Idle and then continue the blend tree.
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      141.2 KB
      Views:
      755
  2. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    I'd need to take a look at the larger window (with your idle animation) to be sure, but it can be one of two problems:
    1. You have one of the speed values of the animation set to a movement speed value. If this is the case, animations cannot be a negative speed.
    2. Your transitions need some work. I think this is the real issue. You said you have (geater or less than .1), but if your speed passes by that value it will transition back! So you need to rethink your transitions. I normally have my idle animation as a part of the 2D Freeform but at the center. Simply remove the idle animation and make your 2D Freeform the "default". Then add another animation to your BlendTree--Idle. Idle position will be at (0, 0) because when speed is 0 for both horizontal and vertical, you want it to be idle. Now when he transitions to backwards from forwards, he will pass the idle animation, but you won't have to wait for the transition to play. :)
     
  3. JohnPet

    JohnPet

    Joined:
    Aug 19, 2012
    Posts:
    85
    Well, i tried what you said. I didn't think of doing that, separating the idle in a blendtree, but its all the same. The idle animation isnt passed.

    Even though I'm happy with the result at this time, I would still like to know if there is a solution. I guess the mistake lies in the code, in the way I calculate the speed.

    Code (CSharp):
    1. anim.SetFloat ("Speed", inputX * inputX + inputY * inputY);
    Here is the image :
     

    Attached Files: