Question by
rickydamta3 · Feb 21, 2016 at 08:09 PM ·
mouselookrotationrotatetowards
Rotate Towards Mouse in 3D
I have a script that let the player rotate towards the mouse,but is only working in orthographic mode.
void FixedUpdate(){
var mousePosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
Quaternion rot = Quaternion.LookRotation (transform.position - mousePosition, Vector3.forward);
transform.rotation = rot;
transform.eulerAngles = new Vector3 (0, 0, transform.eulerAngles.z);
rb.angularVelocity = 0;
}
I need the camera to be in perspective. I think is something to do with ScreenToWorldPoint but i am not sure. Any help or links would be appreciated.Sorry for my english :/
Comment