public void Awake() { Debug.Log("Initializing Player..."); // Ensures there's only one instance of this script. if (Instance != null) { Debug.LogError("Player: more than one instance of singleton found!"); Destroy(gameObject); return; } Instance = this; // The Player always starts the game in regular play mode. isPlaying = true; isPaused = false; // Creates the KeyInventory instance. keyInventory = new KeyInventory(); // Get components ================================================================================================= // Tries getting the necessary components if they are not avaliable. if (movementation == null) { movementation = GetComponent <PlayerMovementation>(); } if (weaponController == null) { weaponController = GetComponent <PlayerWeaponController>(); } if (HUD == null) { HUD = GetComponentInChildren <HUDController>(); } if (entity == null) { entity = GetComponent <PlayerEntity>(); } // ================================================================================================================ // Loads the player inventory if it wasn't reset. if (!StageManager.Instance.GetResetInventory()) { // Loads the inventory for a save if there is one. // TODO: Load // If no save is avaliable gives the Player the first weapon. weaponController.GiveWeapon(0, 0, null); } System.GC.Collect(); // Collects garbage at start to avoid potential lag. }