private void Update() { var screen = Camera.main.WorldToViewportPoint(player.transform.position); if (screen.x < 0 - margin || screen.x > 1 + margin || screen.y < 0 - margin || screen.y > 1 + margin) { player.Kill(); } }