• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Local Multiplayer not disconnecting problem[HELP!]

JDizzle383

Member
the title is just what it says. I am coding a couch coop game and have run into a problem. the controllers connect fine, but won't disconnect properly. here is my relevant code:

Code:
var pad = async_load[? "pad_index"], _i = 0, _found = false;
    switch(async_load[? "event_type"]){
    case "gamepad discovered":                     
        repeat(array_length_1d(players)){
            if(players[_i] == pad){
                _found = true;
                break;
            }
            _i++;
        }
        
        if(!_found){
        gamepad_set_axis_deadzone(pad, 0.5);       // Set the "deadzone" for the axis
    gamepad_set_button_threshold(pad, 0.1);    // Set the "threshold" for the triggers
        {
        // Create a player object and assign it a pad number
        hand[pad] = instance_create_layer(x,y,"Instances0",obj_hand);
        player[pad] = instance_create_layer(x,y,"Instances0",obj_token);
        with (player[pad])
            {
            image_index = pad;
            chip_num = pad;
            }
        with (hand[pad])
            {
            image_index = pad;
            pad_num = pad;
            }
        }
        connected_index++;
        players[@ connected_index] = pad && show_debug_message("Registered player " + string(connected_index) + " with gamepad " + string(pad));
        }else{
            show_debug_message("Pad index " + string(pad) + " is already registered");   
        }
    break;
case "gamepad lost":
repeat(array_length_1d(players))
{
        if(instance_exists(pad))
        {
        instance_destroy(pad);
        _found = false;
        }
    }
}
this code connects all controllers fine, but won't allow them to disconnect properly. any help is appreciated! Thanks in advance!
 
Top