// IMPORTANT: This should never be fixed update. Input always needs to be in normal update, or you constantly drop inputs.
        // TLDR: Use Update() for input and FixedUpdate() for motors/movement
        void Update()
        {
            if (comboBS == null && GameObject.Find("HUD") && GameObject.Find("HUD").GetComponent <ButtonScripts>())
            {
                //Debug.Log("found");
                comboBS = GameObject.Find("HUD").GetComponent <ButtonScripts>(); //.comboUpdate(comboTimer, comboTimeSet, comboMultiplier);
            }
            //Debug.Log("cm " + comboMultiplier);
            //combo stuff
            if (comboBS)
            {
                comboBS.comboUpdate(comboTimer, comboTimeSet, comboMultiplier);
            }

            if (curState != PlayerState.Rider)
            {
                foreach (GameObject go in GameObject.FindGameObjectsWithTag("VisibleWhenPlaying"))
                {
                    go.SetActive(false);
                }
            }

            //update vehicle or rider respectively, depending on state.
            switch (curState)
            {
            //process input for vehicle
            case PlayerState.Vehicle:

                //---------------------------------------------------------speed
                //Speedometer.ShowSpeed(curVehicle.transform.GetComponent<Rigidbody>().velocity.magnitude, 0, 100);

                //speed > boost threshold
                if (curVehicle.transform.GetComponent <Rigidbody>().velocity.magnitude > curVehicle.returnActualMaxSpeed() * selectedCharacter_Prefab.GetComponent <BasicRider>().boostThreshold)
                {
                    if (!prevBoostEffect)
                    {
                        prevBoostEffect = true;
                        curBoostEffect  = Instantiate(boostEffectPrefab, curVehicle.transform.position, curVehicle.transform.rotation);
                        //mainCamera.ChangeDistance(15, 2f);
                    }

                    curBoostEffect.transform.position = curVehicle.transform.position;
                    curBoostEffect.transform.rotation = curVehicle.transform.rotation;
                }
                else
                {
                    if (curBoostEffect != null)
                    {
                        prevBoostEffect = false;
                        //mainCamera.ChangeDistance(10f, 2f);
                        Destroy(curBoostEffect);
                    }
                }

                //---------------------------------------------------------sound
                if (curVehicle.GetComponent <AudioSource>().isPlaying == false)
                {
                    SoundScript.PlaySound(curVehicle.GetComponent <AudioSource>(), "Engine");
                }

                //-------------------------------------------------------input:
                //input horizontal movement
                curVehicle.inputHorz(InputManager.GetAxis("Horizontal"));

                float v_input = InputManager.GetAxis("Vertical") == 0 ? InputManager.GetAxis("Accelerate") : InputManager.GetAxis("Vertical");

                //Debug.Log("1 " + ((v_input / Mathf.Abs(v_input)) * 0.5f) + " 2 " + (v_input * 0.5f) + " 3 " + (((v_input / Mathf.Abs(v_input)) * 0.5f) + (v_input * 0.5f)));

                //(v_input == 0) ? 0.5f : v_input
                //input accelleration
                curVehicle.inputAccel(InputManager.GetAxis("Vertical") == 0 ? InputManager.GetAxis("Accelerate") : InputManager.GetAxis("Vertical"));

                //input vertical movement
                curVehicle.inputVert(InputManager.GetAxis("Vertical"));

                //input jump
                if (InputManager.GetButtonDown("Jump") || curVehicle.GetComponent <BasicVehicle>().broken || curVehicle.transform.position.y < floorPerson - 25)
                {
                    if (curVehicle.GetComponent <BasicVehicle>().broken)
                    {
                        prevBroken = true;
                        if (comboBS)
                        {
                            comboBS.comboEnd(comboMultiplier);
                        }
                        comboMultiplier = 0;
                        comboTimer      = 0;
                    }
                    else
                    {
                        prevBroken = false;
                    }

                    ExitVehicle();

                    break;
                }

                break;

            //process input for air movement
            case PlayerState.Rider:
                if (curRider.cashoutcombo)
                {
                    CashOutCombo();
                }

                //If player has died, whether by ragdolling or being lower than an arbitrary threshold provided by the variable deadFloor.
                if (curRider.checkRagdoll() != null || curRider.transform.position.y < floorPerson)
                {
                    if (Time.timeScale == 1)
                    {
                        SoundScript.PlaySound(playerSource, "Death");

                        if (comboBS)
                        {
                            comboBS.GameOver();
                        }

                        curState = PlayerState.Dead;

                        if (curRider.checkRagdoll() == null)
                        {
                            curRider.spawnRagdoll();
                        }
                        curRagdoll = curRider.checkRagdoll().transform.GetComponent <RagdollStorage>().rb;

                        mainCamera.ChangeFocus(curRagdoll.transform, -1);
                        //mainCamera.ChangeDistance(6f, 2f);
                        curRider.destroyThis();
                    }

                    //drop combo before cashing in for death
                    comboMultiplier = 0;
                    comboTimer      = 0;
                    if (comboBS)
                    {
                        comboBS.comboEnd(comboMultiplier);
                    }

                    break;
                }
                else
                {
                    //only countdown combo in air
                    if (comboTimer > 0)
                    {
                        comboTimer -= Time.deltaTime;
                        if (comboTimer <= 0)
                        {
                            if (comboBS)
                            {
                                comboBS.comboEnd(comboMultiplier);
                            }
                            comboTimer      = 0;
                            comboMultiplier = 0;
                        }
                    }

                    //ENTER VEHICLE
                    if (prevVehicleIntangibility > 0)
                    {
                        prevVehicleIntangibility -= Time.deltaTime;

                        if (curRider.curAbilityAmmo == 0 || curRider.rb.velocity.y <= -50)
                        {
                            prevVehicleIntangibility = 0;
                        }
                        if (prevVehicleIntangibility < 0)
                        {
                            prevVehicleIntangibility = 0;
                        }
                    }
                    //maybe ut this back curRider.vehicleToEnter().gameObject != prevVehicle ||
                    if (curRider.vehicleToEnter() != null && curState != PlayerState.Dead && (prevVehicleIntangibility <= 0 || curRider.vehicleToEnter().gameObject != prevVehicle))
                    {
                        EnterVehicle(curRider.vehicleToEnter());
                        //if(curRider.veh)
                        //curState != PlayerState.Dead && (newVehicle.gameObject != prevVehicle || (newVehicle.easyCheckWheelsOnGround() && newVehicle.getGravity() == Vector3.down) || prevVehicleIntangibility <= 0)
                        break;
                    }
                    else
                    {
                        curRider.rejectVehicleToEnter();
                    }

                    //ambience
                    if (curRider)
                    {
                        ambientSource.volume = 0;    //forever.S curRider.GetComponent<Rigidbody>().velocity.magnitude / 100;
                    }

                    //win
                    if (!win && curRider.goalCollider.collidersCount() > 0)
                    {
                        win = true;

                        if (comboBS && comboMultiplier != 0)
                        {
                            comboBS.comboEnd(comboMultiplier);
                        }
                        comboMultiplier = 0;
                        comboTimer      = 0;

                        GameObject.FindGameObjectWithTag("HUD").GetComponent <timerScript>().setWin();


                        curRider.goalCollider.returnColliders()[0].transform.root.Find("shatter1").gameObject.SetActive(true);
                        curRider.goalCollider.returnColliders()[0].gameObject.SetActive(false);
                        curState = PlayerState.Win;
                        mainCamera.ChangeFocus(curRider.transform, 1);
                        mainCamera.SetCameraPosition(curRider.transform.position + curRider.transform.forward * 1.3f + curRider.transform.up * 1.1f);

                        //curRider.off = true;
                        Rigidbody killrb = curRider.rb;
                        Destroy(curRider);
                        killrb.isKinematic = true;
                        killrb.velocity    = Vector3.zero;

                        SoundScript.PlaySound(playerSource, "Win");
                        if (comboBS)
                        {
                            comboMultiplier = 0;
                            comboBS.comboEnd(comboMultiplier);
                            comboBS.Win(GameObject.FindGameObjectWithTag("HUD").GetComponent <timerScript>().timeRemaining > 0);
                        }
                    }


                    //input horizontal movement
                    curRider.inputHorz(InputManager.GetAxis("Horizontal"));

                    //float v_input = InputManager.GetAxis("Vertical") == 0 ? InputManager.GetAxis("Accelerate") : InputManager.GetAxis("Vertical");


                    //input vertical movement
                    curRider.inputVert(InputManager.GetAxis("Vertical") == 0 ? InputManager.GetAxis("Accelerate") : InputManager.GetAxis("Vertical"));

                    //input fastfall
                    if (InputManager.GetButtonDown("FastFall"))
                    {
                        curRider.inputFastFall(1);
                        SoundScript.PlaySound(playerSource, "Ability");
                    }

                    //input abilty
                    if (InputManager.GetButtonDown("Jump"))
                    {
                        curRider.inputAbility(1);
                    }
                    else if (InputManager.GetButton("Jump"))
                    {
                        curRider.inputAbility(2);
                    }
                    else if (InputManager.GetButtonUp("Jump"))
                    {
                        curRider.inputAbility(3);
                    }
                    else
                    {
                        curRider.inputAbility(0);
                    }

                    //input breakin
                    if (InputManager.GetButtonDown("BreakIn"))
                    {
                        curRider.inputBreakIn(1);
                    }
                    else if (InputManager.GetButton("BreakIn"))
                    {
                        curRider.inputBreakIn(2);
                    }
                    else if (InputManager.GetButtonUp("BreakIn"))
                    {
                        curRider.inputBreakIn(3);
                    }
                    else
                    {
                        curRider.inputBreakIn(0);
                    }
                }


                break;

            case PlayerState.Dead:

                updateReset();

                break;

            default:
                //Debug.Log("ERROR - NO RIDER OR VEHICLE");
                break;
            }
        }