void OnTriggerEnter(Collider other) { if(other.tag.Compare("PlayerRocket") == 0) { Rocket rocket = other.GetComponent<Rocket>(); if(rocket != null) { m_life -= rocket.m_power; if(m_life <= 0) { Destory(this.gameObject); } else if(other.tag.CompareTo("player") == 0) { m_life = 0; Destory(this.gameObject); } } } }
void OnTriggerEnter(Collider other)ide
設置tag 和 Colliderthis
other.tag.CompareTo(TagName);spa
對比tag code