TheYellowArchitect / doubledamnation

Exclusively Co-Op Metroidvania with Movement as smooth as Smash Bros Melee
GNU General Public License v3.0
19 stars 2 forks source link

Detect Controller Disconnection #48

Open TheYellowArchitect opened 2 years ago

TheYellowArchitect commented 2 years ago

What if you play and suddenly you pull back and the wire of your controller gets unplugged? The game doesn't pause. It should.

This is often a problem with problematic controllers (I remember a ps4 one) which have a very "sensitive" wire plug.

Coding Implementation

string[] gamepadNames = Input.GetJoystickNames();
    if (gamepadNames.Length == 0)
        //Give warning

In case controller isnt detected normally (e.g. television controllers also count), make a class where in each Update() checks for each button, and once pressed, destroys itself.