void PlayerInput() { bool isMovingx = false; bool isMovingy = false; if (Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0) { oldCameraRotation = cameraTransform.rotation; // get left to right mouse movement float yRot = Input.GetAxis("Mouse X") * rotationSpeed; // get up and down mouse movement float xRot = Input.GetAxis("Mouse Y") * cameraSpeed; // rotate the player model left and right transform.localRotation *= Quaternion.Euler(0f, yRot, 0f); // rotates the camera up and down laserTransform.localRotation *= Quaternion.Euler(-xRot, 0f, 0f); laserTransform2.localRotation *= Quaternion.Euler(-xRot, 0f, 0f); cameraTransform.localRotation *= Quaternion.Euler(-xRot, 0f, 0f); // clamps the max up and down view cameraTransform.localRotation = ClampRotationAroundXAxis(cameraTransform.localRotation); } if ((Input.GetKey(KeyCode.Space) || Input.GetMouseButton(0)) && RemainingLaserCharge()) { if (cameraTransform.rotation != oldCameraRotation) { laserControllerScript.FireLaser(cameraTransform.rotation); } if (laserParticleStart) { laserObject.GetComponent <ParticleSystem>().Play(); laserObject2.GetComponent <ParticleSystem>().Play(); laserParticleStart = false; } } else if (Input.GetKeyUp(KeyCode.Space) || Input.GetMouseButtonUp(0)) { laserControllerScript.HaltLaser(); laserParticleStart = true; } else if (laserCharge < 1) { laserControllerScript.HaltLaser(); laserObject.GetComponent <ParticleSystem>().Stop(); laserObject2.GetComponent <ParticleSystem>().Stop(); } if (Input.GetKeyDown("r") && !reloading) { if (potionCount > 0) { charController.SetBool("drink", true); ChangePotionCount(-1); SetLaserCharge(laserChargeMax); reloading = true; } } else { reloading = false; //charController.SetBool("drink", false); } if (Input.GetKeyUp(KeyCode.Space) || Input.GetMouseButtonUp(0)) { laserObject.GetComponent <ParticleSystem>().Stop(); laserObject2.GetComponent <ParticleSystem>().Stop(); } if (Input.GetKey("w") && Input.GetKey("s")) { isMovingx = false; } else if (Input.GetKey(KeyCode.LeftShift) && Input.GetKey("w")) { transform.position += transform.TransformDirection(Vector3.forward) * Time.deltaTime * movementForwardSpeed * 2.5f; isMovingx = true; } else if (Input.GetKey("w")) { transform.position += transform.TransformDirection(Vector3.forward) * Time.deltaTime * movementForwardSpeed; isMovingx = true; } else if (Input.GetKey("s")) { transform.position += transform.TransformDirection(-Vector3.forward) * Time.deltaTime * movementBackwardSpeed; isMovingx = true; } else { isMovingx = false; } if (Input.GetKey("a") && Input.GetKey("d")) { isMovingy = false; } else if (Input.GetKey("a")) { transform.position += transform.TransformDirection(Vector3.left) * Time.deltaTime * strafeSpeed; isMovingy = true; } else if (Input.GetKey("d")) { transform.position += transform.TransformDirection(Vector3.right) * Time.deltaTime * strafeSpeed; isMovingy = true; } if (isMovingx || isMovingy) { charController.SetInteger("walk", 1); } else { charController.SetInteger("walk", 0); } if (Input.GetKey("e")) { potionControllerScript.GrabPotion(); } if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey("c")) && crouching == false) { cameraTransform.position += new Vector3(0, crouchDistance * -1, 0); crouching = true; } else if ((Input.GetKeyUp(KeyCode.LeftControl) || Input.GetKeyUp("c")) && crouching == true) { cameraTransform.position += new Vector3(0, crouchDistance, 0); crouching = false; } }