I am trying to figure out a good way to deal with an issue with having the player oriented in the right way in a 2D game.
I have a city area made of buildings that have colliders on them. The player is a rectangle with a rigid body 2d on it with collider(s).
I have tried just using a box collider and currently am using 3 circle colliders.
The user clicks with the mouse on the screen. The player moves towards where they have clicked. The rectangle orients itself at an angle according to how the mouse click is in relation to the player current position. For example if the player clicks at a 45 degree any away from the current position then the rectangle representing the player will rotate to 45 degrees.
The player rectangle can only be at 45 degree increments. So straight up and down, left and right or 45 degrees either way.
This all works really create when the player is out in the open.
The problem comes when the player rectangle moves between the buildings. They have colliders on them to try to keep the player angled correctly. For example if the player is vertical between 2 buildings, but is clicking the mouse to either side, the player rectangle should continue to be vertical even though the mouse click it to the side.
I have an image of the problem.
As you can see the player rectangle is angled when it shouldn’t be.
So I tried making the colliders bigger so that it would stay straight no matter what. The problem then is that when the player rectangle tries to go around a corner like the next intersection below on the image it can’t because the colliders won’t let it.
So I am posting here for ideas.