// Controls the player position. void ControlPosition() { // Makes sure that the player position doesn't go off secreen. Vector3 playerPosition = transform.position; playerPosition.x = Mathf.Clamp(playerPosition.x, -6.7f, 6.7f); // Checks if the player hasn't died. if (playerPosition.y < -4.6f && !_playerDamage.isRespawning) { // Kills the player to respawn them. _rigidbody.isKinematic = true; GetComponent <BoxCollider2D>().enabled = false; _playerDamage.KillPlayer(); } // Sets the player position. transform.position = playerPosition; }