Search Unity

Can I turn off animation position smoothing?

Discussion in '2D' started by Tizizzails, Jan 12, 2020.

Thread Status:
Not open for further replies.
  1. Tizizzails

    Tizizzails

    Joined:
    Oct 24, 2018
    Posts:
    6
    Hello everyone!
    A question about this smoothing effect that I'm seeing. I'm starting off on a new project here where my character is made of three child sprites - weapon, torso, legs. All of my torso sprites are 64x64, leg and weapon sprites vary in size. Each part has its own animator.
    The example I'll talk about is the crouch. It has two animations, each comprised of one new sprite with a change in the position of the sprite. So ideally you would see one frame (of animation) with him going into a crouch and one with him fully crouched. Snap snap! I have to lower the position of the torso sprite so that he'll stay attached to the legs. The legs sprite gets smaller (crouched) but does not change in position.
    The problem is that the animator smoothly moves the torso down while the legs crouch in two quick frames. The torso is drifting through all these x,y positions that I did not explicitly enter into the "position" property in the animation window. So basically he splits in two for a moment until his torso comes down to his legs. When I release the crouch button his legs snap back to a standing position and his torso slowly drifts back onto his waist.
    As a child I tore myself in half doing this and I don't want to see it in my video game. Can I turn this effect off? So that his torso is at one position in one animation frame and then at another position in the next, without the asynchronous drifting? I've done what I consider to be some serious searching with no results.

    Thanks in advance for any pointers!

    I should probably add that there are no changes in position during each animation. Half crouch is one frame at a lower position, full crouch is one frame at an even lower position. So it's basically during the transitions.
     
    Last edited: Jan 12, 2020
  2. ojaoweir

    ojaoweir

    Joined:
    Sep 4, 2019
    Posts:
    2
    Hi,

    I was having the same issue but with my colliders, i wanted them to snap between their positions not smoothly transition.
    I found in the animation window there is this other tab curves:
    upload_2021-2-8_21-23-1.png
    Here we can see (and alter) how the components transition between states. The keyframes are marked with these tiny dots, i have circled them in the image below:
    upload_2021-2-8_21-27-53.png
    For the following example i have highlighted my offset.x so only it's curve is showing. If we click the keyframe we can see this small white arm sticking out from the keyframe (circled in blue):
    upload_2021-2-8_21-29-2.png
    With this arm we can alter the curve of the transition between this key frame and the previous one. If we turn it so it is pointing straight up (or down) we se the curve snaps into a straight shape:
    upload_2021-2-8_21-29-51.png
    Between these two keyframes the offset.x will not smoothen, but will stay at the value of the previous keyframe until we reach the next key frame, where it will snap into the new value.

    This is a bit tedious, since using this method requires you to change the curve at every key frame...
     

    Attached Files:

  3. ojaoweir

    ojaoweir

    Joined:
    Sep 4, 2019
    Posts:
    2
    Another simpler solution is to copy the keyframe of the first state (in your case standing up) and paste it the frame before the next keyframe (in your case crouching). Then no smoothing transition will happen between the first and second keyframes, since there is no difference in the transform between those two states. And then it will snap to the new position (crouch) in the next frame which is the crouch key frame.

    I'll try to show in pictures what i mean. In the first picture I have my two key frames:
    upload_2021-2-8_21-40-31.png
    In the second image I have copied and pasted the first keyframe to the frame before the next keyframe:
    upload_2021-2-8_21-41-11.png
    There will be no smooth transitions between the first and second keyframes since all the values are the same. And between the second and third they will snap from the first values to the second
     
    Usama848 likes this.
  4. Burger_Games

    Burger_Games

    Joined:
    Apr 20, 2021
    Posts:
    2
    Open the Animation window, select curves in the bottom left, drag a square (with the mouse) over all the points in your curves, right-click one of the points, and select both tangents > constant. That at least worked for me
     
    emredesu, Ben_S17, Midas1 and 3 others like this.
  5. shoopi

    shoopi

    Joined:
    Dec 9, 2016
    Posts:
    6
    Thanks @Burger_Games for the correct solution when you want 0 smoothing.
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,500
    Please use the like button rather than necroing threads.

    Thanks.
     
    shoopi likes this.
Thread Status:
Not open for further replies.