Search Unity

Question Issue flipping 2D sprites when using position keyframes

Discussion in '2D' started by lemmons, Mar 25, 2021.

  1. lemmons

    lemmons

    Joined:
    Jun 20, 2016
    Posts:
    68
    I've had to adjust the transform of each sprite to line up correctly and flow with the animation. It looks great when facing left, but when I flip to the right none of the keyframe positions flip with it. I made a short little video to show what I'm talking about.

    I've tried using a negative X scale, flipping X on the Sprite Renderer, and toggling the Mirror option in the animation state machine all to no avail. First x scale and flip x approaches flip the sprite, but jack up the animation while the Mirror option doesn't work at all and upon further inspection only works with a "humanoid rig" which I'm assuming is out of the question for 2d?

    Any guidance would be appreciated, thanks.

    Update: I've found if you nest the actual sprite and flip the scale of the parent object it works just fine. This is great, but feels hacky so if anyone has advice on how to make it work in a more "official" capacity please let me know!
     
    Last edited: Mar 25, 2021
  2. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,462
    This is usually the case. It is easier to have a parent gameobject with scripts on it and then have a child object that handles the graphics. It may feel hacky but ive seen many many tutorials online do it the same. glad you got it working!
     
    lemmons likes this.