void CheckHeadsMoving() { if (!IsOk()) { return; } float left_head_p = m_LeftHead.transform.localPosition.y; float right_head_p = m_RightHead.transform.localPosition.y; // Check for falling one head if (Mathf.Abs(left_head_p - right_head_p) > m_HeadMaxDeltaPos) { MakeOneHeadFalling(left_head_p < right_head_p); } // Check if monster is destroyed const float delta_min = -1.0f; if (Mathf.Max(left_head_p, right_head_p) < m_LeftHeadContr.GetMinPos() + delta_min && IsHeadsOk()) { DestroyTheMonster(); } // Update heads progresess float max_delta_y = 1.5f; float left_head_progress = 1.0f - (left_head_p - (m_LeftHeadContr.GetMinPos() + delta_min)) / max_delta_y; float right_head_progress = 1.0f - (right_head_p - (m_RightHeadContr.GetMinPos() + delta_min)) / max_delta_y; m_LeftHeadContr.UpdateKillProgress(left_head_progress); m_RightHeadContr.UpdateKillProgress(right_head_progress); }