U
U
Uncle Bogdan2021-08-16 13:31:32
Unity
Uncle Bogdan, 2021-08-16 13:31:32

Why does the player look not at the mouse, but a little to the side?

Tipo over time, for some reason, does not look at the mouse, but a little to the side.

private void LookToMouse()
    {
        Vector3 mouseposition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        Vector2 direction = transform.position + mouseposition;
        
        float Angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;

        transform.rotation = Quaternion.AngleAxis(Angle, Vector3.forward);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Siomin, 2021-08-16
@motkot

Errors infloat

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question