void DetectSprintInput()
 {
     if (Input.GetKey(KeyCode.LeftShift))
     {
         SprintInput?.Invoke();
     }
 }
Ejemplo n.º 2
0
 void DetectSprintInput()
 {
     /*bool sprintInput = Input.GetKey(KeyCode.LeftShift);
      * if(sprintInput != false)
      * {
      *  //Debug.Log("Sprint on");
      *  SprintInput?.Invoke();
      * }*/
     if (Input.GetKeyDown(KeyCode.LeftShift))
     {
         SprintInput?.Invoke();
     }
     if (Input.GetKeyUp(KeyCode.LeftShift))
     {
         SprintOffInput?.Invoke();
     }
 }
Ejemplo n.º 3
0
 void DetectSprintInput()
 {
     if (Input.GetKey(KeyCode.LeftShift))
     {
         //process input as a 0 or 1 if avalabile
         float xInput = Input.GetAxisRaw("Horizontal");
         float yInput = Input.GetAxisRaw("Vertical");
         //if we have either one
         if (xInput != 0 || yInput != 0)
         {
             //convert local directions bas on player rotation
             Vector3 _horizontalMovement = transform.right * xInput;
             Vector3 _forwardMovement    = transform.forward * yInput;
             //combine vectors into single vector
             Vector3 sprint = (_horizontalMovement + _forwardMovement).normalized;
             //notify that movement has occured
             SprintInput?.Invoke(sprint);
         }
     }
 }