Question by
BignoseDev · May 21 at 12:48 PM ·
2d2d gamemouseposition2d rotationtop down shooter
2D fixed cam aim problem
Hi my game camera is fixed , i have a script for gun aiming looks like this.
Vector3 mouse = Input.mousePosition; mouse.z = 0f;
Vector3 screenPoint = TheCam.WorldToScreenPoint(transform.localPosition);
Vector2 offset = new Vector2(mouse.x - screenPoint.x, mouse.y-screenPoint.y);
float angle = Mathf.Atan2(offset.y, offset.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0, 0, angle);
this code is only usefull non fixed cams because mouse rotate is set to screen middle if my player go out of middle my gun aim is broken
i how to set my mouse rotation to my Player ? ( The camera is fixed and the player moves independently of the camera.)
Comment
Your answer
Follow this Question
Related Questions
Factorio-like sprite directions 0 Answers
How to fix enemy's rotation (2D) 0 Answers
2D - Flipping a sprite from a different position 0 Answers
How to fix enemy's rotation (2D) 0 Answers