Aiming Direction of Player altered After collision

Hello! I’ve been working on a top down shooter game recently and I’ve run into a weird issue. So I used a vector2 variable to calculate the direction my character should look at (mouse position - rigidbody2d.position), and everything works fine until my character collides with something. After the collision, there’s an offset between my mouse position and where my character looks at and shoot, as illustrated by the images below. I’m suspecting that it has something to do with rigidbody but I’m not sure how to solve it. Any help is greatly appreciated

I have been having this problem for a long while now, but finally found the answer and its quite simple. for the players rigidbody just freeze rotation on the z axis under the Constraints tab. This doesnt freeze the rotation of the gameobject itself. so as long as you are not controlling your characters rotation using the rigidbody and instead you are controlling the rotation using the actual gameobjects transform rotation (which you should) then it will fix your problem!