Advertisement
Guest User

Untitled

a guest
May 3rd, 2015
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. private void GetInput(out float speed)
  2.         {
  3.             // Read input
  4.             float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
  5.             float vertical = CrossPlatformInputManager.GetAxis("Vertical");
  6.  
  7.             bool waswalking = m_IsWalking;
  8.  
  9. #if !MOBILE_INPUT
  10.             // On standalone builds, walk/run speed is modified by a key press.
  11.             // keep track of whether or not the character is walking or running
  12.             m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
  13. #endif
  14.             // set the desired speed to be walking or running
  15.             speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
  16.             m_Input = new Vector2(horizontal, vertical);
  17.  
  18.             // normalize input if it exceeds 1 in combined length:
  19.             if (m_Input.sqrMagnitude > 1)
  20.             {
  21.                 m_Input.Normalize();
  22.             }
  23.  
  24.             // handle speed change to give an fov kick
  25.             // only if the player is going to a run, is running and the fovkick is to be used
  26.             if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
  27.             {
  28.                 StopAllCoroutines();
  29.                 StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
  30.             }
  31.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement