// Update is called once per frame void Update() { if (currentDistanceState != ghostDistance.OnTarget && !isGhostDead) { CheckDistance(); if (chasingPlayer) { transform.position = Vector2.MoveTowards(transform.position, targetObject.transform.position, ghostSpeed); } } else { playerAudio.StopGhostNoises(this.gameObject, true); if (isGhostDead && !playerAudio.CheckGhostDeath()) { playerAudio.RemoveFromGhostList(this.gameObject); playerAudio.GhostDeath(); } } }