// Update is called once per frame void Update() { Vector2 difference = player.transform.position - transform.position; if (difference.magnitude <= playerActivationRange) { objectSpawner.gameObject.SetActive(true); } else { objectSpawner.gameObject.SetActive(false); objectSpawner.ResetSpawnTimer(); } }