void OnTriggerEnter2D(Collider2D collider) { MoonMove moonMove = collider.GetComponent <MoonMove>(); if (moonMove != null) { Falling = true; Destroy(gameObject); } }
// called when hit star & moon void OnTriggerEnter2D(Collider2D collider) { // when hit star Star star = collider.GetComponent <Star>(); if (star != null) { star.Live(); Destroy(gameObject); } // when hit moon MoonMove moonMove = collider.GetComponent <MoonMove>(); if (moonMove != null) { moonMove.Tremble(); Destroy(gameObject); } }