Search code examples
unity-game-engine2d

Unity localScale problem with character stuck in wall


I recently downloaded unity, and I found that the localScale method was a better option for flip a character(especially for the box collider). But when I go close to a wall and turn, my character get stuck in wall. Do Code that I use](https://i.sstatic.net/zHuz1.png) have solutions ?Game preview](https://i.sstatic.net/C7vfj.png)

I tried to make my wall bouce my character and nothing changed, sometimes he got stuck.


Solution

  • enter image description here

    It's easy to solve once you understand the 'base' by which the scale is flipped. No. 1 and 2 of the uploaded image show the x scale value of 1 and -1 when the reference axis is in the center. Numbers 3 and 4 are when the reference axis is moved to the (0, 0.5) position of the image center using the sprite editor, and the x scale value is set to 1, -1 in the same way.