So i have a 2d Character Sprite and standard Movement code that Flips the XScale when moving left.
Then i have a Child Object named(RotToPos) which has a Rotationscript in it that traces to where the mouse is.
Then there is a Child Object of that which Contains (ShootFrom) its used to Fire the projectile from the End of the barrel.
Everything works fine untill you move left and the XScale changes, then everything gets Wonky… Actually its easier if you see it for yourself.
Link to Downloadable File
and yes, i know i didnt fix the Flips Rotation but even when i do it still gets wonky
Script on the RotToPos**
void Update () {
Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10);
Vector3 lookPos = Camera.main.ScreenToWorldPoint(mousePos);
lookPos = lookPos - transform.position;//transform.position-lookPos;//lookPos - transform.position;
float angle = (Mathf.Atan2(lookPos.y, lookPos.x) * Mathf.Rad2Deg);
//if(angle > 90 || angle < -90)
// angle = Mathf.Sign(angle) * 180 - angle;
print ((angle));//-180)*-1);
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);