Make oject to look where your mouse is
Im making top down shooter where you can only stand and aim , whats the best way to do that , I need to make player look where my mouse is on only one of the axis . Thanks in advance , PLS C# only .
Comment
Answer by Jessespike · May 16, 2016 at 08:22 PM
Transforms position from screen space into world space.
Vector3 worldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
transform.LookAt(new Vector3(worldPoint.x, worldPoint.y, transform.localPosition.z)); // XY
//transform.LookAt(new Vector3(worldPoint.x, transform.localPosition.x, worldPoint.z)); // XZ
Um this dosent work , my player rotates but not how it should ... PLS help
unity1.png
(146.4 kB)
unity-2.png
(160.9 kB)