- Home /
Question by
Freak-ey · Dec 31, 2014 at 07:18 PM ·
vector3top downmouse-look
inaccurate top down mouse aim (2D)
I am working on a top down shooter but the mouse aim is slightly off, the character will look slightly away from the crosshair leading to inaccurate shooting.
Vector3 mousePos = Camera.main.ScreenToWorldPoint (Input.mousePosition);
Quaternion rot = Quaternion.LookRotation ((transform.position - mousePos) * Time.deltaTime, Vector3.forward);
transform.rotation = rot;
transform.eulerAngles = new Vector3 (0, 0, transform.eulerAngles.z);
rigidbody2D.angularVelocity = 0.1f;
Are there any ways to make this code more accurate or, in the case that there aren't, any alternatives?
Comment
Your answer
Follow this Question
Related Questions
Can't use camera.main [SOLVED] 1 Answer
moving object whilst keeping a constant y position 3 Answers
Can someone help me to understand what vector3.lerp does and can be used for 2 Answers
problem Changing Scales in Script -C# 4 Answers
Cannot modify a value type return value of `UnityEngine.Transform.position'. Can anyone help ? 1 Answer