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

Changing movement direction messes with sprite

Discussion in '2D' started by MrSanfrinsisco, Oct 6, 2019.

  1. MrSanfrinsisco

    MrSanfrinsisco

    Joined:
    Jan 17, 2018
    Posts:
    31
    I downloaded a free player sprite off the asset store, and I noticed after creating a script to allow my player to move, when I switch from moving left or right, instead of rotating on a center joint, he changes the direction he's facing and ALSO his current position. It causes some problems such as allowing the player the get stuck in a wall, or even teleport themselves off the platform. I've attached a video to show you exactly what I mean.
     
  2. Ledesma099

    Ledesma099

    Joined:
    May 15, 2018
    Posts:
    26
    How are you doing the flip?

    Because if you change localPosition or localScale to flip your player. Instead, you can flip the character through the SpriteRenderer
     
  3. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    i think, it flips around the sprite pivot point (somewhere at the nose from this pet). You can move the sprite renderer on the child object and make it bit offset on the x-axis from the main object with collider and other things. Or move the pivot point in the sprite editor to the middle of the body.