- Home /
Question by
MegaBlueBerry · Aug 21, 2020 at 10:04 PM ·
2dspritemouse
Rotating a sprite distorts it?
I have a section of code that is supposed to rotate the player's gun to follow the mouse but when it rotates The sprite gets smooshed like it's trying to fill a square and is stretching it towards the corners.
var dir = Input.mousePosition - Camera.main.WorldToScreenPoint(transform.position);
var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
any ideas?
Comment
Your answer
Follow this Question
Related Questions
Drag and Drop w/ Snapping 0 Answers
LookAt() not working with mouse as target in 2D 1 Answer
Display sprite where clicked on screen. 1 Answer
How do I drag a sprite around? 2 Answers
Mouse Click Based Movement/Actions & 2D Sprite Rotation in 3D Space 0 Answers