This question was
closed May 15, 2017 at 01:41 PM by
Pypsikan for the following reason:
The question is answered, right answer was accepted
Identify weapon
How to identify what "BOX" was killed by "sword"
void Update() {
if (curHealth < 1) {
Destroy(gameObject);
}
}
if "box" have < 1 hp then Destroy. I tried through:
void OnCollisionEnter2D(Collision2D col) {
if (col.collider.CompareTag("Weapon") && curHealth < 1) {
gm.points += coins;
}
}
But did not help.
Comment
Answer by Pypsikan · May 15, 2017 at 01:40 PM
Done.
void OnTriggerEnter2D(Collider2D col) {
if (col.gameObject.CompareTag("Weapon") && curHealth < 2) {
Destroy(gameObject);
gm.points += coins;
}
}