- Home /
Question by
hyperduck · Dec 11, 2017 at 03:39 PM ·
quaternionsinput.mouseposition
Cant Rotate in Unity Survival Shooting Game tutorial
I recently picked up Unity and was learning from the survival shooter course by Unity. Haven't completed the course yet but tried the movement script that was provided but my character model couldn't rotate in the game window. No error was shown in the debug log. Any idea why that is?
void Turning() { Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit floorhit;
if (Physics.Raycast(camRay, out floorhit, camRayLength, floormask)){
Vector3 playerToMouse = floorhit.point - transform.position;
playerToMouse.y = 0f;
Quaternion newRotation = Quaternion.LookRotation(playerToMouse);
playerRigidBody.MoveRotation(newRotation);
}
}
Comment
Your answer
Follow this Question
Related Questions
Moving to worldpoint from mouse position 1 Answer
Change Movespeed based on Mouse Input 0 Answers
Rotating an object in level editor 1 Answer
Inverse of Quaternion.eulerAngles? 0 Answers