Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Move() {
- isCrouching = Input.GetButton ("Crouch");
- lookAngle = Mathf.Clamp(lookAngle + (Input.GetAxis ("Mouse Y") * lookSensitivity), -90, 90);
- transform.Rotate(0, Input.GetAxis ("Mouse X") * lookSensitivity, 0);
- cc.height = Mathf.Lerp (cc.height, (isCrouching ? 0.5f : 2), 10 * Time.deltaTime);
- cam.transform.position = (transform.position + (transform.up * (isCrouching ? eyeCrouch : eyeStand))) + (Random.insideUnitSphere*viewShake);
- cam.transform.rotation = Quaternion.Euler (-lookAngle, transform.rotation.eulerAngles.y, Mathf.LerpAngle(cam.transform.rotation.eulerAngles.z, Input.GetAxis("Horizontal")*(camTiltMagnitude/(isCrouching ? 2 : 1)) + viewPunch, 10 * Time.deltaTime));
- if (!hasLanded && cc.isGrounded) {
- hasLanded = true;
- fall = 0;
- }
- if (fall < Physics.gravity.y) {
- hasLanded = false;
- }
- if (hasLanded) {
- if (cc.isGrounded)
- fall = 0;
- if (Input.GetKey (KeyCode.Space)) {
- fall = jumpStrength;
- hasLanded = false;
- }
- }
- fall += Physics.gravity.y * Time.deltaTime;
- finalMove.y = 0;
- finalMove.x = Input.GetAxis ("Horizontal") * moveSpeed/(isCrouching ? 2 : 1);
- finalMove.z = Input.GetAxis ("Vertical") * moveSpeed/(isCrouching ? 2 : 1);
- stepTimer += finalMove.magnitude*Time.deltaTime;
- finalMove.y = fall;
- finalMove = transform.rotation * finalMove;
- cc.Move (finalMove * Time.deltaTime);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement