// Update is called once per frame
    void Update()
    {
        if (inputDevice != null && game_manager.gstate != vars.game_state.win_sequenze)
        {
            //ROTATE CHARAKTER IN MOVING DIRECTION
            if (rotation_update_timer_curr >= rotation_update_timer_toggle)
            {
                rotation_update_timer_curr = 0.0f;
                if (rd.velocity.x > -roation_change_velocity && rd.velocity.x < roation_change_velocity)
                {
                    if (enable_fron_rotation) { player_model_holder.transform.rotation = Quaternion.Euler(270, 0, 0); view_dir = vars.view_direction.front; }
                }
                else if (rd.velocity.x > roation_change_velocity)
                {
                    player_model_holder.transform.rotation = Quaternion.Euler(270, 90, 0);
                    view_dir = vars.view_direction.right;
                }
                else if (rd.velocity.x < -roation_change_velocity)
                {
                    player_model_holder.transform.rotation = Quaternion.Euler(270, -90, 0);
                    view_dir = vars.view_direction.left;
                }
                else
                {
                    if (enable_fron_rotation) { player_model_holder.transform.rotation = Quaternion.Euler(270, 0, 0); view_dir = vars.view_direction.front; }
                }
            }
            else
            {
                rotation_update_timer_curr += Time.deltaTime;
            }

            //MOVE GROUND
            if (inputDevice.LeftStick.Left && isGrounded && !btn_triggered(inputDevice, vars.player_controls.carry_down) && !knocked_down)
            {
                if (ball_instance.carried_by == this.player_id)
                {
                    rd.AddForce(new Vector3(1.0f, 0.0f, 0.0f) * speed_multiplier_ground_carry);
                }
                else {
                    rd.AddForce(new Vector3(1.0f, 0.0f, 0.0f) * speed_multiplier_ground);
                }

            }
            if (inputDevice.LeftStick.Right && isGrounded && !btn_triggered(inputDevice, vars.player_controls.carry_down) && !knocked_down)
            {
                if (ball_instance.carried_by == this.player_id)
                {
                    rd.AddForce(new Vector3(-1.0f, 0.0f, 0.0f) * speed_multiplier_ground_carry);
                }
                else
                {
                    rd.AddForce(new Vector3(-1.0f, 0.0f, 0.0f) * speed_multiplier_ground);
                }

            }
            //MOVE AIR
            if (inputDevice.LeftStick.Left && !isGrounded && !btn_triggered(inputDevice, vars.player_controls.carry_down) && !knocked_down)
            {
                if (ball_instance.carried_by == this.player_id)
                {
                    rd.AddForce(new Vector3(1.0f, 0.0f, 0.0f) * speed_multiplier_air_carry);
                }
                else
                {
                    rd.AddForce(new Vector3(1.0f, 0.0f, 0.0f) * speed_multiplier_air);
                }
            }
            if (inputDevice.LeftStick.Right && !isGrounded && !btn_triggered(inputDevice, vars.player_controls.carry_down) && !knocked_down)
            {
                if (ball_instance.carried_by == this.player_id)
                {
                    rd.AddForce(new Vector3(-1.0f, 0.0f, 0.0f) * speed_multiplier_air_carry);
                }
                else
                {
                    rd.AddForce(new Vector3(-1.0f, 0.0f, 0.0f) * speed_multiplier_air);
                }
            }

            // JUMP X/A
            if (btn_triggered(inputDevice, vars.player_controls.jump) && !btn_triggered(inputDevice, vars.player_controls.jump, true) && this.transform.position.y <= jump_height_ground_trigger && !btn_triggered(inputDevice, vars.player_controls.carry_down) && !knocked_down)
            {
                //  rd.velocity = new Vector3(0.0f, 0.0f, 0.0f);
                if(ball_instance.carried_by == this.player_id)
                {
                    rd.AddForce(new Vector3(0.0f, 1.0f * jump_height_carry, 0.0f));
                }
                else
                {
                    rd.AddForce(new Vector3(0.0f, 1.0f * jump_height, 0.0f));
                }

                player_stat.jumps++;
            }

            //RESET GAME
            if (btn_triggered(inputDevice, vars.player_controls.menu) && (game_manager.gstate == vars.game_state.playing || game_manager.gstate == vars.game_state.win_sequenze) && player_id == vars.player_id.player_1)
            {
                GameObject.Find("game_manager").GetComponent<game_manager>().reset_game();
            }

            //PUNSH
            if (btn_triggered(inputDevice, vars.player_controls.punsh) && !punsh_state && game_manager.gstate == vars.game_state.playing && !knocked_down)
            {
                do_punsh();
            }

            //CARRY UP
            if (btn_triggered(inputDevice, vars.player_controls.carry_up) && game_manager.gstate == vars.game_state.playing && !knocked_down)
            {
                ball_instance.carry(player_id);
            }

            //CARRY DOWN AND FLY
            if (ball_instance.carried_by == player_id && game_manager.gstate == vars.game_state.playing)
            {
                //last state = true und now state = true
                if (btn_triggered(inputDevice, vars.player_controls.carry_down, true) && btn_triggered(inputDevice, vars.player_controls.carry_down))
                {
                    //throw_parable_min
                    float ty = (float)(inputDevice.LeftStick.X); //-1 - +1 -> 0 - 1
                    if (ty > 0 && view_dir == vars.view_direction.left)
                    {
                        throw_parable_velocity = Vector3.Lerp(new Vector3(throw_parable_min.x, throw_parable_min.y, -throw_parable_min.z), new Vector3(throw_parable_max.x, throw_parable_max.y, -throw_parable_max.z), ty);
                    }
                    else if (ty < 0 && view_dir == vars.view_direction.right)
                    {
                        throw_parable_velocity = Vector3.Lerp(new Vector3(throw_parable_min.x, throw_parable_min.y, throw_parable_min.z), new Vector3(throw_parable_max.x, throw_parable_max.y, throw_parable_max.z), -ty);
                    }
                    setTrajectoryPoints(new Vector3(throwDirectionObject.position.z, throwDirectionObject.position.y, throwDirectionObject.position.x), throw_parable_velocity);
                    //last state = true und now state = false -> werfen
                }
                else if (!btn_triggered(inputDevice, vars.player_controls.carry_down) && btn_triggered(inputDevice, vars.player_controls.carry_down, true))
                {
                    throw_parable_velocity += this.rd.velocity;
                  //  ball_instance.decarry_fly(player_id, player_id, new Vector3(throw_parable_velocity.z * throw_ball_multiplier.x, throw_parable_velocity.y * throw_ball_multiplier.y, throw_parable_velocity.x * throw_ball_multiplier.z));
                    throw_points_cleared = false;
                    clearTrajectoryPoints();
                }
            }
            else
            {
                clearTrajectoryPoints();
            }

            //PUNSH TIMER
            if (punsh_state)
            {
                if (curr_punsh_duration <= 0.0f)
                {
                    punsh_collider.enabled = false;
                    punsh_obj.transform.localPosition = punsh_start_position;
                    //curr_punsh_duration = punsh_duration;
                    punsh_state = false;
                    punsh_cooldown_state = true;
                    curr_punsh_cooldown = punsh_cooldown_duration;
                }
                else
                {
                    curr_punsh_duration -= Time.deltaTime;
                }
            }

            //PUNSH COOLDOWN TIMER
            if (punsh_cooldown_state)
            {
                if (curr_punsh_cooldown <= 0.0f)
                {
                    punsh_cooldown_state = false;
                }
                else
                {
                    curr_punsh_cooldown -= Time.deltaTime;
                }
            }

            //RUMBLE TIMER (WINDOWS ONLY)
            if (rumble_timer_current >= rumble_timer_max && rumble_active)
            {
                rumble_timer_current = 0.0f;
                inputDevice.Vibrate(0.0f);
                rumble_active = false;
            }
            else
            {
                if (rumble_active)
                {
                    rumble_timer_current += Time.deltaTime;
                }
            }

            //KNOCK DOWN TIMER
            if (knock_down_timer_current > 0.0f && knocked_down)
            {
                knock_down_timer_current -= Time.deltaTime;
            }
            else if (knocked_down)
            {
                knocked_down = false;
            }

            if (last_nock_time >= knock_down_time_limit && curr_knocks > 0)
            {
                is_knock_limit_running = false;
                curr_knocks = 0;
            }
            else
            {
                if (game_manager.gstate == vars.game_state.playing)
                {
                    last_nock_time += Time.deltaTime;
                }

            }

        }
        else
        {
            if (game_manager.gstate == vars.game_state.spawn)
            {
                if (inputDevice != null)
                {
                    is_playing = true;
                    game_manager.player_count++;
                    GameObject.Find("UI_MAIN_HOLDER").GetComponent<ingame_gui_manager>().refresh_count_ui();
                }
                else
                {
                    if (pid >= 0)
                    {
                        inputDevice = (InputManager.Devices.Count > pid) ? InputManager.Devices[pid] : null;
                    }
                }
            }

        }
    }
 public void set_model_roation_to_front()
 {
     player_model_holder.transform.rotation = Quaternion.Euler(270, 0, 0);
     view_dir = vars.view_direction.front;
 }