// called when hit by NPC object
    public void OnHit(int damagePoints, Vector3 hitPos)
    {
        // do nothing if already dead or no damage
        if (IsDead() || (damagePoints <= 0))
        {
            return;
        }

        // handle death & callbacks
        if (damagePoints >= m_life)
        {
            Kill();
        }
        else
        {
            m_life -= damagePoints;

            // hit!
            // enable god mode if not already done
            if (!m_godMode)
            {
                m_godMode     = true;
                m_godModeTime = Time.time;
                if (m_anim)
                {
                    m_anim.SetBool("GodMode", true);
                }

                // add small impulse in opposite direction
                Vector2 v2Dir = transform.position - hitPos;
                m_player.SetVelocity(new Vector2((v2Dir.x > 0f ? 1f : -1f) * m_hitImpulse.x, m_hitImpulse.y));
            }
        }
    }
    // called when character is entering this collectable
    public void OnTriggerEnter2D(Collider2D otherCollider)
    {
        // do nothing if not ebabled
        if (!enabled)
        {
            return;
        }

        if (m_playing)
        {
            // update playing state
            float fAnimTime = m_anim.GetCurrentAnimatorStateInfo(0).normalizedTime;
            if (fAnimTime >= 1f)
            {
                m_playing = false;
            }
            else
            {
                // do not allow impulse during play
                return;
            }
        }

        APCharacterController character = otherCollider.GetComponent <APCharacterController>();

        if (character != null)
        {
            m_playing = true;
            m_anim.Play(m_animHash, 0, 0f);

            // launch impulse/jump
            if (m_mode == EImpulseMode.Impulse)
            {
                float   fAngle       = -Mathf.Deg2Rad * m_impulseDirection;
                Vector2 v2ImpulseDir = new Vector2(Mathf.Cos(fAngle), -Mathf.Sin(fAngle));
                v2ImpulseDir = transform.TransformDirection(v2ImpulseDir);

                Vector2 charVel         = character.GetVelocity();
                float   velAlongImpulse = Vector2.Dot(charVel, v2ImpulseDir);
                charVel += v2ImpulseDir * (m_impulsePower - velAlongImpulse);
                character.SetVelocity(charVel);
            }
            else
            {
                character.Jump(m_jumpMinHeight, m_jumpMaxHeight);
            }
        }
    }