예제 #1
0
        public void Collide()
        {
            m_body.velocity = Vector2.zero;

            var contactAnim = m_animator.FindAnimation("contact");

            if (contactAnim == null)
            {
                Destroy(gameObject);
                return;
            }

            contactAnim.loop = false;
            contactAnim.AddFinishEvent(() => Destroy(gameObject));
            m_animator.SetAnimation("contact");
        }
예제 #2
0
        protected void Die()
        {
            m_body.velocity = Vector2.zero;

            if (m_dieSound != null)
            {
                AudioSource.PlayClipAtPoint(m_dieSound, Camera.main.transform.position, 0.8f);
            }

            var deathAnimation = m_animator.FindAnimation("die");

            if (deathAnimation == null)
            {
                Destroy(gameObject);
                return;
            }

            deathAnimation.loop = false;
            deathAnimation.AddFinishEvent(() => Destroy(gameObject));

            m_animator.SetAnimation("die");
        }