- Home /
Question by
Spacemarine658 · Dec 17, 2015 at 10:49 AM ·
3dplayerlookatcamera-look
Player looking script
i setup a script to follow the players mouse but it won't continue to rotate if the mouse is off screen any help? (3d btw)
void FixedUpdate()
{
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition + Vector3.forward * 2f);
Vector3 direction = mousePos - transform.position;
Quaternion toRotation = Quaternion.FromToRotation(transform.forward, direction);
transform.rotation = Quaternion.Lerp(transform.rotation, toRotation, 0.1f * Time.time);
}
Comment
Your answer
Follow this Question
Related Questions
LookAt and Follow different objects 0 Answers
my screen keeps on jittering when I play what is wrong? here is my camera and movement script 1 Answer
Problem with resolution in build the game 0 Answers
Virtual joystick problem issue 1 Answer
,Look rotation viewing vector is zero and character always facing 1 direction when idle 0 Answers