// Update is called once per frame
    void Update()
    {
        if (CharacterManager.InstanceExists)
        {
            int iDinoType = CharacterManager.Instance.m_iDinoTypes[m_cPlayerNumber - 1];
            m_dinos[iDinoType].GetComponentInChildren <SkinnedMeshRenderer>().material = CharacterManager.Instance.m_dinoColours[m_cPlayerNumber - 1];
        }
        if (OptionsManager.InstanceExists)
        {
            m_weapon.GetComponent <AudioSource>().volume = OptionsManager.Instance.m_fMasterVolume * OptionsManager.Instance.m_fSFXVolume * m_fOriginalVolume;
        }

        if (!m_rigidbody.isKinematic)
        {
            m_cAttackAmount = 0;
        }

        // get controller input
        m_gamePadState = GamePad.GetState(m_playerIndex);
        // Get player input (keyboard)
        Vector2 v2Movement = new Vector2(Input.GetAxis("Horizontal" + m_cPlayerNumber.ToString()), Input.GetAxis("Vertical" + m_cPlayerNumber.ToString()));

        // Get player input (controller)
        v2Movement.x += m_gamePadState.ThumbSticks.Left.X;
        v2Movement.y += m_gamePadState.ThumbSticks.Left.Y;
        v2Movement.Normalize();

        // KONAMI
        KONAMI(m_gamePadState);

        // checks if the player is in the crane
        if (m_bInCrane && !m_bIsAttacking && !m_bIsOut)
        {
            m_claw.Move(v2Movement.x, v2Movement.y, m_fClawSpeed);
        }
        // checks if the player is on cruise control
        else if (m_cruiseControl.bFlag && !m_bIsOut && !m_bInCrane)
        {
            if (m_fKnockedBackTimer <= 0.0f)
            {
                Cruise(v2Movement.x, v2Movement.y);
            }
            else
            {
                Move(v2Movement.x, v2Movement.y);
            }

            // look to movement
            if (v2Movement.sqrMagnitude != 0.0f && Time.timeScale > 0.0f && !m_bKonami)
            {
                transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(new Vector3(v2Movement.x, 0.0f, v2Movement.y)), m_fCruiseRotateSpeed);
            }
        }
        // checks if the player is in the game and not on cruise control
        else if (!m_bIsOut && !m_bInCrane)
        {
            Move(v2Movement.x, v2Movement.y);

            // look to movement
            if (v2Movement.sqrMagnitude != 0.0f && Time.timeScale > 0.0f && !m_bKonami)
            {
                transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(new Vector3(v2Movement.x, 0.0f, v2Movement.y)), m_fRotateSpeedController);
            }
        }

        // pause game
        if (!m_gameManager.m_bPlayerWon && (Input.GetButtonDown("Pause" + m_cPlayerNumber.ToString()) || (m_gamePadState.Buttons.Start == ButtonState.Pressed && !m_bPauseButtonDown)))
        {
            if (Time.timeScale > 0.0f)
            {
                Time.timeScale = 0.0f;
                m_pauseGameCanvas.gameObject.SetActive(true);
                m_pauseGameCanvas.m_buttons[0].Select();
            }
            else
            {
                Time.timeScale = 1.0f;
                m_pauseGameCanvas.ResetAlpha();
                m_pauseGameCanvas.gameObject.SetActive(false);
            }

            m_bPauseButtonDown = true;
        }
        else if (m_gamePadState.Buttons.Start == ButtonState.Released)
        {
            m_bPauseButtonDown = false;
        }

        // Activate dash (keyboard || controller)
        if ((Input.GetButtonDown("Jump" + m_cPlayerNumber.ToString()) || m_gamePadState.Triggers.Left > 0.0f) && !m_bIsOut && !m_bInCrane)
        {
            GetComponent <Dash>().DoDash();
        }

        if (!m_rigidbody.isKinematic && !m_bIsOut && !m_bInCrane)
        {
            RaycastHit ray = new RaycastHit();

            // Get origin of raycast above player so it doesn't bug when just using player position
            Vector3 v3OriginPos = transform.position;
            v3OriginPos.y += 1.0f;
            // raycast to hit ground
            if (Physics.Raycast(v3OriginPos, Vector3.down, out ray, m_fHoverHeight) &&
                ray.collider.CompareTag("Ground"))
            {
                m_rigidbody.AddForce(Vector3.up * m_rigidbody.mass * (m_fHoverForce - (transform.position.y * m_fHeightFromHoverMultiplier)) * Time.deltaTime);
            }
        }

        // Nullify angular velocity so it doesn't conflict with quaternion lerp
        m_rigidbody.angularVelocity = new Vector3(0, 0, 0);

        //Correct X and Z rotation of object
        transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0.0f, transform.rotation.eulerAngles.y, 0.0f), m_fCorrectionSpeed);

        // checks if the player is in the crane and a button is pressed
        if (m_bInCrane && !m_bIsOut && !m_bAttackButtonDown &&
            (m_gamePadState.Triggers.Right > 0.0f || m_gamePadState.Triggers.Left > 0.0f ||
             m_gamePadState.Buttons.RightShoulder == 0 || m_gamePadState.Buttons.LeftShoulder == 0 ||
             m_gamePadState.Buttons.A == 0 || m_gamePadState.Buttons.B == 0 ||
             m_gamePadState.Buttons.X == 0 || m_gamePadState.Buttons.Y == 0 ||
             Input.GetAxis("Fire" + m_cPlayerNumber.ToString()) > 0.0f))
        {
            // sets the player to attacking
            m_bIsAttacking = true;
        }
        // checks if the fire button was pressed
        else if (!m_bIsOut && !m_bAttackButtonDown && (m_gamePadState.Triggers.Right > 0.0f || Input.GetAxis("Fire" + m_cPlayerNumber.ToString()) > 0.0f) && !m_bIsAttacking)
        {
            // sets the player to attacking
            m_bIsAttacking = true;
        }

        if (m_gamePadState.Triggers.Right > 0.0f)
        {
            m_bAttackButtonDown = true;
        }
        else
        {
            m_bAttackButtonDown = false;
        }

        // checks if the player is grabbing another with the claw or dropping an item
        if (m_bIsAttacking && m_bInCrane && !m_bIsOut && !m_claw.m_delay.bFlag)
        {
            // checks if the claw has a player
            if (m_claw.m_bHasPlayer)
            {
                // attempts to drop the player
                m_bIsAttacking = m_claw.DropPlayer();
            }
            // checks if there is an item to drop
            else if (m_claw.m_bHasItem && !m_claw.m_bDropped)
            {
                m_claw.DropItem();
                m_bIsAttacking = false;
            }
            else
            {
                // grabs with the claw
                m_bIsAttacking = m_claw.Grab();
            }
        }
        else if (m_bIsAttacking && !m_bIsOut)
        {
            // swings the weapon
            Attack();
        }

        if (m_weaponSize.bFlag)
        {
            // decrements the timer
            m_weaponSize.fTimer -= Time.deltaTime;
            // checks if the timer has run out
            if (m_weaponSize.fTimer <= 0.0f)
            {
                // resets the weapon size
                m_weaponSize.bFlag               = false;
                m_weaponSize.fTimer              = m_fWeaponSizeTime;
                m_weapon.transform.localScale    = m_v3BaseWeaponScale;
                m_weapon.transform.localPosition = m_v3BaseWeaponPosition;
            }
        }

        if (m_cruiseControl.bFlag)
        {
            // decrements the timer
            m_cruiseControl.fTimer -= Time.deltaTime;
            // checks if the timer has run out
            if (m_cruiseControl.fTimer <= 0.0f)
            {
                // resets the cruise control
                m_cruiseControlParticle.SetActive(false);
                m_cruiseControl.bFlag  = false;
                m_cruiseControl.fTimer = m_fCruiseControlTime;
                m_rigidbody.velocity   = new Vector3(v2Movement.x * m_fVelocity, m_rigidbody.velocity.y, v2Movement.y * m_fVelocity);
            }
        }

        if (m_bVibrating)
        {
            m_fVibrationTimer -= Time.deltaTime;

            if (m_fVibrationTimer <= 0.0f)
            {
                GamePad.SetVibration((PlayerIndex)m_cPlayerNumber - 1, 0.0f, 0.0f);
                m_bVibrating = false;
            }
        }

        m_fKnockedBackTimer -= Time.deltaTime;
    }