diff --git a/Assets/Scripts/InputSystem/PlayerInput.cs b/Assets/Scripts/InputSystem/PlayerInput.cs index 6e29de66..f8668236 100644 --- a/Assets/Scripts/InputSystem/PlayerInput.cs +++ b/Assets/Scripts/InputSystem/PlayerInput.cs @@ -47,7 +47,7 @@ namespace HeavenStudio public static InputController.ControlStyles CurrentControlStyle = InputController.ControlStyles.Pad; - static List inputDevices; + static List inputDevices = new List(); public delegate InputController[] InputControllerInitializer(); @@ -126,6 +126,7 @@ namespace HeavenStudio //so such controllers should have a reference to the other controller in the pair foreach (InputController i in inputDevices) { + if (i == null) continue; if (i.GetPlayer() == player) { return i; @@ -142,6 +143,7 @@ namespace HeavenStudio //controller IDs are determined by connection order (the Keyboard is always first) for (int i = 0; i < inputDevices.Count; i++) { + if (inputDevices[i] == null) continue; if (inputDevices[i].GetPlayer() == player) { return i; @@ -152,8 +154,10 @@ namespace HeavenStudio public static void UpdateInputControllers() { + if (inputDevices == null) return; foreach (InputController i in inputDevices) { + if (i == null) continue; i.UpdateState(); } }