- Home /
Perfect movement towards camera forward
the code below works but the problem is velocity changes magnificently when i look up with camera or look down.
what do you think the problem?
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.S))
cc.Move(new Vector3(mainCamera.transform.forward.x, 0, mainCamera.transform.forward.z).normalized * 0.01f * (Input.GetKey(KeyCode.W) ? _speed : -_speed));
if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.A))
cc.Move(new Vector3(mainCamera.transform.right.x, 0, mainCamera.transform.right.z).normalized * 0.01f * (Input.GetKey(KeyCode.D) ? _speed : -_speed));
Comment