Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. void Move() {
  2.         isCrouching = Input.GetButton ("Crouch");
  3.  
  4.         lookAngle = Mathf.Clamp(lookAngle + (Input.GetAxis ("Mouse Y") * lookSensitivity), -90, 90);
  5.  
  6.         transform.Rotate(0, Input.GetAxis ("Mouse X") * lookSensitivity, 0);
  7.  
  8.         cc.height = Mathf.Lerp (cc.height, (isCrouching ? 0.5f : 2), 10 * Time.deltaTime);
  9.  
  10.         cam.transform.position = (transform.position + (transform.up * (isCrouching ? eyeCrouch : eyeStand))) + (Random.insideUnitSphere*viewShake);
  11.         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));
  12.  
  13.         if (!hasLanded && cc.isGrounded) {
  14.             hasLanded = true;
  15.             fall = 0;
  16.         }
  17.  
  18.         if (fall < Physics.gravity.y) {
  19.             hasLanded = false;
  20.         }
  21.  
  22.         if (hasLanded) {
  23.             if (cc.isGrounded)
  24.                 fall = 0;
  25.             if (Input.GetKey (KeyCode.Space)) {
  26.                 fall = jumpStrength;
  27.                 hasLanded = false;
  28.             }
  29.         }
  30.  
  31.         fall += Physics.gravity.y * Time.deltaTime;
  32.  
  33.         finalMove.y = 0;
  34.         finalMove.x = Input.GetAxis ("Horizontal")  * moveSpeed/(isCrouching ? 2 : 1);
  35.         finalMove.z = Input.GetAxis ("Vertical") * moveSpeed/(isCrouching ? 2 : 1);
  36.         stepTimer += finalMove.magnitude*Time.deltaTime;
  37.         finalMove.y = fall;
  38.  
  39.  
  40.         finalMove = transform.rotation * finalMove;
  41.  
  42.         cc.Move (finalMove * Time.deltaTime);
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement