FOVKickUp() public method

public FOVKickUp ( ) : IEnumerator
return IEnumerator
Beispiel #1
0
        private void GetInput(out float speed)
        {
            // Read input
            float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            float vertical   = CrossPlatformInputManager.GetAxis("Vertical");

            bool waswalking = m_IsWalking;

            // set the desired speed to be walking or running
            speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
Beispiel #2
0
        private void GetInput(out float speed)
        {
            // Read input
            float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            float vertical   = CrossPlatformInputManager.GetAxis("Vertical");

            bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            // set the desired speed to be walking or running
            speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
Beispiel #3
0
    public void GetInput(out float speed)
    {
        float horizontal = 0.0f;
        float vertical   = 0.0f;

        if (PlayerNumber == 1)
        {
            horizontal = -Input.GetAxis("PlayerOne_Vertical");
            vertical   = Input.GetAxis("PlayerOne_Horizontal");
        }
        if (PlayerNumber == 2)
        {
            horizontal = -Input.GetAxis("PlayerTwo_Vertical");
            vertical   = Input.GetAxis("PlayerTwo_Horizontal");
        }

        bool waswalking = isWalking;

        if (PlayerNumber == 1)
        {
            isWalking = !Input.GetButtonDown("PlayerOne_Jump");
        }
        if (PlayerNumber == 2)
        {
            isWalking = !Input.GetButtonDown("PlayerTwo_Jump");
        }

        if (isWalking)
        {
            speed = walkSpeed;
        }
        else
        {
            speed = runSpeed;
        }

        userInput = new Vector2(horizontal, vertical);

        // normalize input if it exceeds 1 in combined length:
        if (userInput.sqrMagnitude > 1)
        {
            userInput.Normalize();
        }

        // handle speed change to give an fov kick
        // only if the player is going to a run, is running and the fovkick is to be used
        if (isWalking != waswalking && useFovKick && characterController.velocity.sqrMagnitude > 0)
        {
            StopAllCoroutines();
            if (isWalking)
            {
                StartCoroutine(fovKick.FOVKickUp());
            }
            else
            {
                StartCoroutine(fovKick.FOVKickDown());
            }
        }
    }
Beispiel #4
0
 public void DoFoveKick()
 {
     if (!m_useFovKick)
     {
         return;
     }
     StopAllCoroutines();
     StartCoroutine(!FirstPersonController.m_isWalking ? m_fovKick.FOVKickUp() : m_fovKick.FOVKickDown());
 }
        private void GetInput(out float speed)
        {
            // Read input

            //horizontal Right-Left Movement
            //Vertical Up-Down Movement
            float horizontal = 0; // = CrossPlatformInputManager.GetAxis("Horizontal");
            float vertical   = 0; // = CrossPlatformInputManager.GetAxis("Vertical");

            Debug.DrawRay(transform.position, cam.transform.forward * 100, Color.red);
            Debug.DrawRay(transform.position, transform.forward * 100, Color.green);

            angGO  = new Vector2(transform.forward.x, transform.forward.z);
            angCam = new Vector2(cam.transform.forward.x, cam.transform.forward.z);

            angle = Vector2.SignedAngle(angGO, angCam);

            if (Input.GetKey(KeyCode.B) || canMove)
            {
                horizontal = -Mathf.Sin(angle * Mathf.PI / 180f);
                vertical   = Mathf.Cos(angle * Mathf.PI / 180f);

                //print("Angle: " + angle + " ( Horizontal: " + horizontal + " Sin: " + Mathf.Sin(angle) + " ) " + " ( Vertical: " + vertical + " Cos: " + Mathf.Cos(angle) + " ) ");
            }
            else
            {
                horizontal = 0;
                vertical   = 0;
            }



            bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            // set the desired speed to be walking or running
            speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
        private void GetInput(out float speed)
        {
            // Read input
            float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            float vertical   = CrossPlatformInputManager.GetAxis("Vertical");

            bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            // set the desired speed to be walking or running
            speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            if (Input.GetKey(KeyCode.LeftShift))
            {
                m_CharacterController.height = originalHeight / 8;
                m_IsCrouching = true;
            }
            else
            {
                m_CharacterController.height = originalHeight;
                m_IsCrouching = false;
            }
            if (Input.mouseScrollDelta.y < 0)
            {
                int slot = (selectedWeapon - 1 < 0) ? weapons.Length - 1 : selectedWeapon - 1;
                SelectWeapon(slot);
            }
            else if (Input.mouseScrollDelta.y > 0)
            {
                int slot = (selectedWeapon + 1 == weapons.Length) ? 0 : selectedWeapon + 1;
                SelectWeapon(slot);
            }

            if (weapon != null)
            {
                weapon.isRunning = !m_IsWalking;
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
Beispiel #7
0
        private void GetInput(out float speed)
        {
            // Read input.
//			if (GvrController.IsTouching) {
//				speed = 10f;
//				m_Input = GvrController.TouchPos;
//				if (m_Input.sqrMagnitude > 1)
//				{
//					m_Input.Normalize();
//				}
//				return;
//			}


            if (CrossPlatformInputManager.GetButtonDown("Recenter"))
            {
                UnityEngine.VR.InputTracking.Recenter();
            }

            float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            float vertical   = CrossPlatformInputManager.GetAxis("Vertical");

#if UNITY_HAS_GOOGLEVR && (UNITY_ANDROID || UNITY_EDITOR)
            horizontal = GvrController.ClickButton ? 0f : horizontal;
            vertical   = GvrController.ClickButton ? 1f :vertical;
#endif

            Debug.Log("Unit#: horizontal = " + horizontal + " vertical = " + vertical);
            bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif

            //			Debug.Log ("Unit#: Is Touching = " + GvrController.ClickButton + " X = " + GvrController.TouchPos.x + " Y = " + GvrController.TouchPos.y);
//			Debug.Log ("Unit#: x_accel = " + GvrController.Accel.x + " y_accel = " + GvrController.Accel.y + " z_accel = " + GvrController.Accel.z);
            // set the desired speed to be walking or running
            speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
        private void GetInput(out float speed)
        {
            // Read input
            float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            float vertical   = CrossPlatformInputManager.GetAxis("Vertical");

            bool waswalking = m_IsWalking;

                        #if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking  = true;
            m_IsCrouched = Input.GetKey(KeyCode.LeftControl);
            bool prevDash = m_IsDashing;
            m_IsDashing = (Input.GetKey(KeyCode.LeftShift) && m_Energy > 99 && !prevDash) ||
                          (Input.GetKey(KeyCode.LeftShift) && m_Energy > 32 && prevDash)
            ;

            if (m_IsDashing)
            {
                //m_AudioSource.clip = dashClip;// m_JumpSound;
                //m_AudioSource.Play();
                if (m_Energy > 99)
                {
                    DashAudioSource.PlayOneShot(dashClip, 0.6f);
                }
                //SoundManager.PlaySingleSfx(dashClip);
                Camera.main.GetComponent <CameraEffects>().DashCameraZoom();
                isDashing_delayed = true;
                Invoke("setDashingDelayedFalse", 0.5f);
            }
                        #endif
            // set the desired speed to be walking or running
            speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            if (m_IsDashing)
            {
                speed = m_RunSpeed * m_DashMultiplier;
            }
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
    private void CheckFOVKick()
    {
        bool waswalking = !isRunning;

        // handle speed change to give an fov kick only if the player is going to a run, is running and the fovkick is to be used
        if (!isRunning != waswalking && useFovKick && controller.velocity.sqrMagnitude > 0)
        {
            StopAllCoroutines();
            StartCoroutine(isRunning ? fovKick.FOVKickUp() : fovKick.FOVKickDown());
        }
    }
        private void GetInput(out float speed)
        {
            // Read input
            float horizontal;
            float vertical;

            if (canMove)
            {
                horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
                vertical   = CrossPlatformInputManager.GetAxis("Vertical");
            }
            else
            {
                horizontal = 0;
                vertical   = 0;
            }

            //transform.Rotate(0,horizontal*90*Time.deltaTime*2,0,Space.Self);
            bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            // set the desired speed to be walking or running
            speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);
            //print(vertical);
            if (vertical == 0)
            {
                anim.SetBool("isMove", false);
                //Cmd_rabbit_anim_stop();
            }
            else
            {
                anim.SetBool("isMove", true);
                //Cmd_rabbit_anim_move();
            }
            //Cmd_rabbit_anim(vertical);
            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
Beispiel #11
0
        private void GetInput(out float speed)
        {
            // Read input
            float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            float vertical   = CrossPlatformInputManager.GetAxis("Vertical");

            bool waswalking = _isWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            _isWalking = !Input.GetKey(KeyCode.LeftShift);

            //moritz
            if (vertical > 0)
            {
                nowWalking = true;
            }

            if (vertical <= 0)
            {
                nowWalking = false;
            }


            bool Crouch = Input.GetButton("Fire2");
            if (Crouch)
            {
                _isWalking = true;
            }

            //new animations for input variables moritz
//			anim.SetBool("Sprint", !_isWalking);
            anim.SetBool("Crouch", Crouch);
            anim.SetBool("Walking", nowWalking);
#endif
            // set the desired speed to be walking or running
            speed  = _isWalking ? walkSpeed : runSpeed;
            _input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (_input.sqrMagnitude > 1)
            {
                _input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (_isWalking != waswalking && useFOVKick && _characterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!_isWalking ? _fovKick.FOVKickUp() : _fovKick.FOVKickDown());
            }
        }
    private void GetInput()
    {
        // Read input
        float horizontal = Input.GetAxis("Horizontal");
        float vertical   = Input.GetAxis("Vertical");

        waswalking = m_IsWalking;

        // m_IsCrouching = Input.GetButton("Crouch");

        // On standalone builds, walk/run speed is modified by a key press.
        // keep track of whether or not the character is walking or running
        //if (!m_IsCrouching)
        {
            //   m_IsWalking = !Input.GetButton("Sprint");

            //  if (!m_Jump)
            {
                //      m_Jump = Input.GetButtonDown("Jump");
            }
        }

        // set the desired speed to be walking or running
        speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
        m_Input = new Vector2(horizontal, vertical);

        // normalize input if it exceeds 1 in combined length:
        if (m_Input.sqrMagnitude > 1)
        {
            m_Input.Normalize();
        }

        // handle speed change to give an fov kick
        // only if the player is going to a run, is running and the fovkick is to be used
        if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
        {
            StopAllCoroutines();
            StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
        }
    }
Beispiel #13
0
        //აქ დაწერილია სიარულის სკრიფტი
        private void GetInput(out float speed)
        {
            float horizontal = Input.GetAxis("Horizontal");
            float vertical   = Input.GetAxis("Vertical");

            if (!IsGrounded)
            {
                if (!skipMovement)
                {
                    moveHozBeforeJump  = horizontal;
                    moveVertBeforeJump = vertical;

                    skipMovement = true;
                }
                else
                {
                    horizontal = moveHozBeforeJump;
                    vertical   = moveVertBeforeJump;
                }
            }
            else
            {
                skipMovement = false;
            }

            bool waswalking = m_IsWalking;



            if (!m_IsAiming)
            {
                speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            }
            else
            {
                speed = m_WalkSpeed * 0.8f;
            }

            m_Input = new Vector2(horizontal, vertical);

            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
Beispiel #14
0
//		void OnCollisionEnter (Collision col)
//		{
//			//		Destroy(col.gameObject);
//			print (gameObject.name);
//
//			if(col.gameObject.name == "Floor")
//			{
//				//			Destroy(gameObject);
//				//			print ("HEY");
//				//			GameObject player = GameObject.Find (col.gameObject.name);
//				//			player.transform.position.Set (0, 0, 10);
//
//			}
//		}
//
        private float GetInput() //now returns a float. no longer takes out speed
        {
            // Read input
            float horizontal = Random.Range(-1, 2);
            float vertical   = Random.Range(-1, 2);

            if (m_CharacterController.transform.position.x > 25)
            {
                horizontal = Random.Range(-1, 1);
            }
            else if (m_CharacterController.transform.position.x < -25)
            {
                horizontal = Random.Range(0, 2);
            }
            if (m_CharacterController.transform.position.z > 25)
            {
                vertical = Random.Range(-1, 1);
            }
            else if (m_CharacterController.transform.position.z < -25)
            {
                vertical = Random.Range(0, 2);
            }

            bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            // set the desired speed to be walking or running
            speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
            return(speed);
        }
 static int FOVKickUp(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         FOVKick obj = (FOVKick)ToLua.CheckObject <FOVKick>(L, 1);
         System.Collections.IEnumerator o = obj.FOVKickUp();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #16
0
    private void GetInput(out float speed)
    {
        if (Cursor.visible)
        {
            m_Input = new Vector2(0f, 0f);
            speed   = 0f;
            return;
        }
        // Read input
        var horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
        var vertical   = CrossPlatformInputManager.GetAxis("Vertical");


        var waswalking = m_IsWalking;

                #if !MOBILE_INPUT
        // On standalone builds, walk/run speed is modified by a key press.
        // keep track of whether or not the character is walking or running
        m_IsWalking = !CrossPlatformInputManager.GetButton("Sprint");
                #endif
        // set the desired speed to be walking or running

        speed = m_Flying ? m_FlySpeed : m_WalkSpeed;

        if (!m_IsWalking)
        {
            speed *= m_SprintMultiplier * (CrossPlatformInputManager.GetButton("Sprint2") ? 5f : 1f);
        }

        m_Input = new Vector2(horizontal, vertical);

        // normalize input if it exceeds 1 in combined length:
        if (m_Input.sqrMagnitude > 1)
        {
            m_Input.Normalize();
        }

        // handle speed change to give an fov kick
        // only if the player is going to a run, is running and the fovkick is to be used
        if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
        {
            StopAllCoroutines();
            StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
        }
    }
Beispiel #17
0
        private void GetInput(out float speed)
        {
            float power = 4f;
            float ang   = m_agent.action.rotate * 90f / 16f + 5.0f * CrossPlatformInputManager.GetAxis("Horizontal");

            transform.rotation *= Quaternion.Euler(new Vector3(0, ang, 0));
            // Read input
            float horizontal = 0;
            float vertical   = m_agent.action.forward * power + CrossPlatformInputManager.GetAxis("Vertical");

            m_Jump = m_Jump || m_agent.action.canJump;
            if (m_Jumping)
            {
                m_Jump = false;
            }

            //m_agent._actAppliedCnt++;
            //bool waswalking = m_IsWalking;

            /*
             #if !MOBILE_INPUT
             * // On standalone builds, walk/run speed is modified by a key press.
             * // keep track of whether or not the character is walking or running
             * m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
             #endif
             */
            // set the desired speed to be walking or running
            speed   = m_RunSpeed * m_agent.action.scale;
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
//            if (m_Input.sqrMagnitude > 1)
//            {
//                m_Input.Normalize();
//            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (/*m_IsWalking != waswalking && m_UseFovKick &&*/ m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
Beispiel #18
0
        private void GetInput(out float speed)
        {
            // Read input
            var horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            var vertical   = CrossPlatformInputManager.GetAxis("Vertical");

            var waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            // set the desired speed to be walking or running
            if (m_Submerged)
            {
                speed = m_IsWalking || m_Stamina == 0 ? m_SwimSpeed : m_QuickSwimSpeed;
            }
            else
            {
                speed = m_IsWalking || m_Stamina == 0 ? m_WalkSpeed : m_RunSpeed;
            }
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
            // Update stanima
            // TODO Maybe add a new capacity for stanima?
            m_Stamina = !m_IsWalking?Mathf.MoveTowards(m_Stamina, 0f, Time.deltaTime *m_LungCapacity * 2) : m_Stamina = Mathf.MoveTowards(m_Stamina, 1f, Time.deltaTime * m_LungCapacity * 5);
        }
Beispiel #19
0
    private void GetInput(out float speed)
    {
        // Read input
        float horizontal = Input.GetAxis("Horizontal");
        float vertical   = Input.GetAxis("Vertical");

        Character.Animator.SetFloat("Dirx", horizontal);
        Character.Animator.SetFloat("Diry", vertical);

        m_isIdle = horizontal == 0 && vertical == 0;

        bool waswalking = m_isWalking;

        m_isWalking = !Input.GetKey(KeyCode.LeftShift);

        if (!m_isWalking && CurrentStamina == 0)
        {
            m_isWalking = true;
        }

        // set the desired speed to be walking or running
        speed   = m_isWalking ? m_walkSpeed : m_runSpeed;
        m_Input = new Vector2(horizontal, vertical);

        // normalize input if it exceeds 1 in combined length:
        if (m_Input.sqrMagnitude > 1)
        {
            m_Input.Normalize();
        }

        // handle speed change to give an fov kick
        // only if the player is going to a run, is running and the fovkick is to be used
        if (m_isWalking != waswalking && m_useFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
        {
            StopAllCoroutines();
            StartCoroutine(!m_isWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
        }
        else
        {
        }
    }
Beispiel #20
0
        private void GetInput(out float speed)
        {
            if (_gameManager.HumanNumPadActive ||
                _inventory.InventoryActive ||
                _gameManager.HumanMapActive ||
                _gameManager.HumanController.Health <= 0 ||
                _gameManager.HumanImageCanvasActive ||
                _startMenu.MenuActive)
            {
                speed = 2;
                return;
            }

            // Read input
            var horizontal = CrossPlatformInputManager.GetAxis(ButtonNames.MoveHumanX);
            var vertical   = CrossPlatformInputManager.GetAxis(ButtonNames.MoveHumanY);
            var waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            // set the desired speed to be walking or running
            speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
Beispiel #21
0
        private void GetInput(out float speed)
        {
            // Read input
            float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            float vertical   = CrossPlatformInputManager.GetAxis("Vertical");

            /*// Use last device which provided input.
             * var inputDevice = InputManager.ActiveDevice;
             *
             * // Disable and hide touch controls if we use a controller.
             * // If "Enable Controls On Touch" is ticked in Touch Manager inspector,
             * // controls will be enabled and shown again when the screen is touched.
             * if (inputDevice != InputDevice.Null && inputDevice != TouchManager.Device) {
             *  TouchManager.ControlsEnabled = false;
             * }*/

            bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            // set the desired speed to be walking or running
            speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
        private void GetInput(out float speed)
        {
            float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            float vertical   = CrossPlatformInputManager.GetAxis("Vertical");

            bool waswalking = m_IsWalking;

            speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);

            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
Beispiel #23
0
        private void GetInput(out float speed)
        {
            // Read input
            float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            float vertical   = CrossPlatformInputManager.GetAxis("Vertical");

            bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            // set the desired speed to be walking or running
            speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);

            //locks camera control to allow UI specific control, and vice versa
            //added to first person controller script as it only impacts the FPS controller activity?
            if (Input.GetKeyDown(KeyCode.Escape) && lockCameraDelay <= 0)
            {
                m_LockedCamera = !m_LockedCamera;
                m_MouseLook.SetCursorLock(m_LockedCamera);
                lockCameraDelay = 1.5f;
            }

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
        private void GetInput(out float speed)
        {
            // Read input
            var horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            var vertical   = CrossPlatformInputManager.GetAxis("Vertical");

            var waswalking = _isWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            _isWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            // set the desired speed to be walking or running
            if (_underWater.IsSubmerged())
            {
                speed = _isWalking || !_stamina.HasStamina() ? _swimSpeed : _quickSwimSpeed;
            }
            else
            {
                speed = _isWalking || !_stamina.HasStamina() ? _walkSpeed : _runSpeed;
            }

            _input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (_input.sqrMagnitude > 1)
            {
                _input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to run, is running and the fovkick is to be used
            if (_isWalking != waswalking && _useFovKick && _characterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!_isWalking ? _fovKick.FOVKickUp() : _fovKick.FOVKickDown());
            }
        }
Beispiel #25
0
    private Vector2 GetInput()
    {
        Vector2 input = new Vector2
        {
            x = Input.GetAxis("Horizontal"),
            y = Input.GetAxis("Vertical")
        };

        movementSettings.UpdateDesiredTargetSpeed(input);

        bool wasWalking = !Running;

        Running = Input.GetKey(KeyCode.LeftShift); //Keep track of whether or not the character is walking or running.

        if (!Running != wasWalking && useFovKick && rigidBody.velocity.sqrMagnitude > 0f)
        {
            StopAllCoroutines();
            StartCoroutine(Running ? fovKick.FOVKickUp() : fovKick.FOVKickDown());
        }

        return(input);
    }
    void GetInput(out float speed)
    {
        // Read input
        float horizontal = Input.GetAxis("Horizontal");
        float vertical   = Input.GetAxis("Vertical");

        bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
        // On standalone builds, walk/run speed is modified by a key press.
        // keep track of whether or not the character is walking or running
        m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
        speed   = DesiredSpeed();
        m_Input = new Vector2(horizontal, vertical);

        // normalize input if it exceeds 1 in combined length:
        if (m_Input.sqrMagnitude > 1)
        {
            m_Input.Normalize();
        }

        // handle speed change to give an fov kick
        // only if the player is going to a run, is running and the fovkick is to be used
        if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
        {
            StopAllCoroutines();
            StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
        }

        if (m_ControllerExt)
        {
            bool    isMoving       = (m_Input != Vector2.zero);
            Vector2 animationSpeed = m_IsWalking ? m_Input * 0.5f : m_Input;
            m_ControllerExt.OnMove(isMoving, animationSpeed, false);
        }
    }
    private void GetInput(out float speed)
    {
        // Read input
#if INPUT_MANAGER
        float horizontal = bl_Input.HorizontalAxis;
        float vertical   = bl_Input.VerticalAxis;
#else
        float horizontal = Input.GetAxis("Horizontal");
        float vertical   = Input.GetAxis("Vertical");
#endif
        m_Input = new Vector2(horizontal, vertical);
        PlayerState waswalking = State;

#if !INPUT_MANAGER
        if (m_Input.magnitude > 0 && m_CharacterController.isGrounded)
        {
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            if (Input.GetKey(KeyCode.LeftShift) && State != PlayerState.Crouching)
            {
                State = PlayerState.Running;
            }
            else if (Input.GetKeyUp(KeyCode.LeftShift) && State != PlayerState.Crouching)
            {
                State = PlayerState.Walking;
            }
            else if (State != PlayerState.Crouching)
            {
                State = PlayerState.Walking;
            }
        }
        else if (State != PlayerState.Jumping && State != PlayerState.Crouching)
        {
            State = PlayerState.Idle;
        }
#else
        if (m_Input.magnitude > 0 && m_CharacterController.isGrounded)
        {
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            if (bl_Input.GetKey("Run") && State != PlayerState.Crouching)
            {
                State = PlayerState.Running;
            }
            else if (bl_Input.GetKeyUp("Run") && State != PlayerState.Crouching)
            {
                State = PlayerState.Walking;
            }
            else if (State != PlayerState.Crouching)
            {
                State = PlayerState.Walking;
            }
        }
        else if (State != PlayerState.Jumping && State != PlayerState.Crouching)
        {
            State = PlayerState.Idle;
        }
#endif

        if (Crounching)
        {
            speed = m_CrouchSpeed;
        }
        else
        {
            // set the desired speed to be walking or running
            speed = (State == PlayerState.Running) ? m_RunSpeed : m_WalkSpeed;
        }


        // normalize input if it exceeds 1 in combined length:
        if (m_Input.sqrMagnitude > 1)
        {
            m_Input.Normalize();
        }

        // handle speed change to give an fov kick
        // only if the player is going to a run, is running and the fovkick is to be used
        if (State != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0 && State == PlayerState.Running)
        {
            StopAllCoroutines();
            StartCoroutine((State == PlayerState.Running) ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
        }
    }
        private void GetInput(out float speed)
        {
            // Read input
            float horizontal = Input.GetAxis("Horizontal");
            float vertical   = Input.GetAxis("Vertical");

            bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            // set the desired speed based on state
            if (anim.GetCurrentAnimatorStateInfo(0).IsName("Idle/Walk/Run"))
            {
                if (weaponManager.GetEquippedWeapon() == null)
                {
                    if (cameraManager.GetAiming())
                    {
                        speed = m_IsWalking ? m_WalkSpeed * .50f : m_RunSpeed * .25f + (m_RunSpeed * noWeaponSpeed);
                    }
                    else
                    {
                        speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed + (m_RunSpeed * noWeaponSpeed);
                    }
                }
                else if (cameraManager.GetAiming())
                {
                    speed = m_IsWalking ? m_WalkSpeed * .50f : m_RunSpeed * .25f;
                }
                else
                {
                    speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
                }
            }
            else if (anim.GetCurrentAnimatorStateInfo(0).IsName("Crouch"))
            {
                if (cameraManager.GetAiming())
                {
                    speed = m_IsWalking ? m_WalkSpeed * .40f : m_RunSpeed * .15f;
                }
                else
                {
                    speed = m_IsWalking ? m_WalkSpeed * .75f : m_RunSpeed * .5f;
                }
            }
            else if (anim.GetCurrentAnimatorStateInfo(0).IsName("Prone"))
            {
                speed = m_WalkSpeed / 5f;
            }
            else
            {
                speed = m_WalkSpeed;
            }

            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }
            anim.SetFloat("Vertical", m_Input.y * speed / m_WalkSpeed);
            anim.SetFloat("Horizontal", m_Input.x * speed / m_WalkSpeed);
            if (m_Crouching)
            {
                wasCrouching = !wasCrouching;
                anim.SetBool("Crouch", wasCrouching);
            }
            if (m_Prone)
            {
                wasProne = !wasProne;
                anim.SetBool("Prone", wasProne);
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }
Beispiel #29
0
using System;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
using UnityStandardAssets.Utility;
using Random = UnityEngine.Random;

namespace UnityStandardAssets.Characters.FirstPerson
{
	[RequireComponent(typeof (CharacterController))]
	[RequireComponent(typeof (AudioSource))]
	public class FirstPersonController : MonoBehaviour
	{
		[SerializeField] private bool m_IsWalking;
		[SerializeField] private float m_WalkSpeed;
		float ogWalkSpeed;

		[SerializeField] private float m_WaterSpeed;
		[SerializeField] private float m_RunSpeed;
		[SerializeField] [Range(0f, 1f)] private float m_RunstepLenghten;
		[SerializeField] private float m_JumpSpeed;
		[SerializeField] private float m_StickToGroundForce;
		[SerializeField] private float m_GravityMultiplier;
		[SerializeField] private MouseLook m_MouseLook;
		[SerializeField] private bool m_UseFovKick;
		[SerializeField] private FOVKick m_FovKick = new FOVKick();
		[SerializeField] private bool m_UseHeadBob;
		[SerializeField] private CurveControlledBob m_HeadBob = new CurveControlledBob();
		[SerializeField] private LerpControlledBob m_JumpBob = new LerpControlledBob();
		[SerializeField] private float m_StepInterval;
		[SerializeField] private AudioClip[] m_FootstepSounds;    // an array of footstep sounds that will be randomly selected from.
		[SerializeField] private AudioClip[] m_WaterSounds;
		[SerializeField] private AudioClip m_JumpSound;           // the sound played when character leaves the ground.
		[SerializeField] private AudioClip m_LandSound;           // the sound played when character touches back on ground.


		private RaycastHit ground;
		private Camera m_Camera;
		private bool m_Jump;
		private float m_YRotation;
		private Vector2 m_Input;
		private Vector3 m_MoveDir = Vector3.zero;
		private CharacterController m_CharacterController;
		private CollisionFlags m_CollisionFlags;
		private bool m_PreviouslyGrounded;
		private Vector3 m_OriginalCameraPosition;
		private float m_StepCycle;
		private float m_NextStep;
		private bool m_Jumping;
		private AudioSource m_AudioSource;

		public bool inWater;
		public bool inGrass;

		// Use this for initialization
		private void Start()
		{
			ogWalkSpeed = m_WalkSpeed;

			m_CharacterController = GetComponent<CharacterController>();
			m_Camera = Camera.main;
			m_OriginalCameraPosition = m_Camera.transform.localPosition;
			m_FovKick.Setup(m_Camera);
			m_HeadBob.Setup(m_Camera, m_StepInterval);
			m_StepCycle = 0f;
			m_NextStep = m_StepCycle/2f;
			m_Jumping = false;
			m_AudioSource = GetComponent<AudioSource>();
			m_MouseLook.Init(transform , m_Camera.transform);
		}


		// Update is called once per frame
		private void Update()
		{
			RotateView();
			// the jump state needs to read here to make sure it is not missed
			if (!m_Jump)
			{
				m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
			}

			if (!m_PreviouslyGrounded && m_CharacterController.isGrounded)
			{
				StartCoroutine(m_JumpBob.DoBobCycle());
				PlayLandingSound();
				m_MoveDir.y = 0f;
				m_Jumping = false;
			}
			if (!m_CharacterController.isGrounded && !m_Jumping && m_PreviouslyGrounded)
			{
				m_MoveDir.y = 0f;
			}


			m_PreviouslyGrounded = m_CharacterController.isGrounded;
		}


		private void PlayLandingSound()
		{
			m_AudioSource.clip = m_LandSound;
			m_AudioSource.Play();
			m_NextStep = m_StepCycle + .5f;
		}


		private void FixedUpdate()
		{
			float speed;
			GetInput(out speed);
			// always move along the camera forward as it is the direction that it being aimed at
			Vector3 desiredMove = transform.forward*m_Input.y + transform.right*m_Input.x;

			// get a normal for the surface that is being touched to move along it
			RaycastHit hitInfo;
			Physics.SphereCast(transform.position, m_CharacterController.radius, Vector3.down, out hitInfo,
				m_CharacterController.height/2f, Physics.AllLayers, QueryTriggerInteraction.Ignore);
			desiredMove = Vector3.ProjectOnPlane(desiredMove, hitInfo.normal).normalized;

			m_MoveDir.x = desiredMove.x*speed;
			m_MoveDir.z = desiredMove.z*speed;


			if (m_CharacterController.isGrounded)
			{
				m_MoveDir.y = -m_StickToGroundForce;

				if (m_Jump)
				{
					m_MoveDir.y = m_JumpSpeed;
					PlayJumpSound();
					m_Jump = false;
					m_Jumping = true;
				}
			}
			else
			{
				m_MoveDir += Physics.gravity*m_GravityMultiplier*Time.fixedDeltaTime;
			}
			m_CollisionFlags = m_CharacterController.Move(m_MoveDir*Time.fixedDeltaTime);

			ProgressStepCycle(speed);
			UpdateCameraPosition(speed);

			m_MouseLook.UpdateCursorLock();

		}


		private void PlayJumpSound()
		{
			m_AudioSource.clip = m_JumpSound;
			m_AudioSource.Play();
		}


		private void ProgressStepCycle(float speed)
		{
			if (m_CharacterController.velocity.sqrMagnitude > 0 && (m_Input.x != 0 || m_Input.y != 0))
			{
				m_StepCycle += (m_CharacterController.velocity.magnitude + (speed*(m_IsWalking ? 1f : m_RunstepLenghten)))*
					Time.fixedDeltaTime;
			}

			if (!(m_StepCycle > m_NextStep))
			{
				return;
			}

			m_NextStep = m_StepCycle + m_StepInterval;

			PlayFootStepAudio();
		}

		private void PlayFootStepAudio()
		{
			if (!m_CharacterController.isGrounded)
			{
				return;
			}

			if (inWater) 
			{
				PlayWaterStepAudio ();
				m_WalkSpeed = m_WaterSpeed;
				return;
			}

			m_WalkSpeed = ogWalkSpeed;

			// pick & play a random footstep sound from the array,
			// excluding sound at index 0
			int n = Random.Range(1, m_FootstepSounds.Length);
			m_AudioSource.clip = m_FootstepSounds[n];
			m_AudioSource.PlayOneShot(m_AudioSource.clip);
			// move picked sound to index 0 so it's not picked next time
			m_FootstepSounds[n] = m_FootstepSounds[0];
			m_FootstepSounds[0] = m_AudioSource.clip;

		}

		private void PlayWaterStepAudio()
		{

			// pick & play a random footstep sound from the array,
			// excluding sound at index 0
			int n = Random.Range(1, m_WaterSounds.Length);
			m_AudioSource.clip = m_WaterSounds[n];
			m_AudioSource.PlayOneShot(m_AudioSource.clip);
			// move picked sound to index 0 so it's not picked next time
			m_WaterSounds[n] = m_WaterSounds[0];
			m_WaterSounds[0] = m_AudioSource.clip;

		}


		private void UpdateCameraPosition(float speed)
		{
			Vector3 newCameraPosition;
			if (!m_UseHeadBob)
			{
				return;
			}
			if (m_CharacterController.velocity.magnitude > 0 && m_CharacterController.isGrounded)
			{
				m_Camera.transform.localPosition =
					m_HeadBob.DoHeadBob(m_CharacterController.velocity.magnitude +
						(speed*(m_IsWalking ? 1f : m_RunstepLenghten)));
				newCameraPosition = m_Camera.transform.localPosition;
				newCameraPosition.y = m_Camera.transform.localPosition.y - m_JumpBob.Offset();
			}
			else
			{
				newCameraPosition = m_Camera.transform.localPosition;
				newCameraPosition.y = m_OriginalCameraPosition.y - m_JumpBob.Offset();
			}
			m_Camera.transform.localPosition = newCameraPosition;
		}


		private void GetInput(out float speed)
		{
			// Read input
			float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
			float vertical = CrossPlatformInputManager.GetAxis("Vertical");

			bool waswalking = m_IsWalking;

			#if !MOBILE_INPUT
			// On standalone builds, walk/run speed is modified by a key press.
			// keep track of whether or not the character is walking or running
			m_IsWalking = !Input.GetKey(KeyCode.LeftShift);

			#endif
			// set the desired speed to be walking or running
			speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
			m_Input = new Vector2(horizontal, vertical);

			// normalize input if it exceeds 1 in combined length:
			if (m_Input.sqrMagnitude > 1)
			{
				m_Input.Normalize();
			}

			// handle speed change to give an fov kick
			// only if the player is going to a run, is running and the fovkick is to be used
			if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
			{
				StopAllCoroutines();
				StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
			}
		}


		private void RotateView()
		{
			m_MouseLook.LookRotation (transform, m_Camera.transform);
		}


		private void OnControllerColliderHit(ControllerColliderHit hit)
		{
			Rigidbody body = hit.collider.attachedRigidbody;
			//dont move the rigidbody if the character is on top of it
			if (m_CollisionFlags == CollisionFlags.Below)
			{
				return;
			}

			if (body == null || body.isKinematic)
			{
				return;
			}
			body.AddForceAtPosition(m_CharacterController.velocity*0.1f, hit.point, ForceMode.Impulse);
		}
	}
}


        private void GetInput(out float speed)
        {
            // Read input
            float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            float vertical   = CrossPlatformInputManager.GetAxis("Vertical");

            bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            m_isCrouching = Input.GetKey(KeyCode.C);


            // set the desired speed to be walking,running,crouching

            // TAG: RUNNING

            if (!m_isCrouching)
            {
                if (m_IsWalking)
                {
                    speed = m_WalkSpeed;
                    if (stamina < max_stamina)
                    {
                        stamina += Time.deltaTime * staminaRecovery;
                    }
                }
                else
                {
                    if (stamina > 0)
                    {
                        m_IsWalking = false;
                        stamina    -= Time.deltaTime;
                    }
                    else
                    {
//						print ("Should be walking.");
                        m_IsWalking = true;
                    }
                }

                speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
                m_Input = new Vector2(horizontal, vertical);
            }
            else
            {
                speed = m_crouch_speed;
            }
            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }

            staminaSlider.value = stamina;
        }