I have a rigidbody that has a FPS camera attached to it. How I make it move is by using this script I came up with :
void Move() {
Camera cam = Camera.main;
if (Input.GetKey(KeyCode.UpArrow)) {
transform.Translate(cam.transform.forward * move_speed);
}
if (Input.GetKey (KeyCode.RightArrow)) {
transform.Translate (cam.transform.TransformDirection(Vector3.right) * move_speed);
}
if (Input.GetKey (KeyCode.LeftArrow)) {
transform.Translate (cam.transform.TransformDirection(Vector3.left) * move_speed);
}
if (Input.GetKey (KeyCode.DownArrow)) {
transform.Translate (cam.transform.TransformDirection(Vector3.b) * move_speed);
}
}
Works pretty well, except when I look up, my player “jumps” up. How can I detect and cancel this movement? Thanks!