- Home /
Question by
XxKingKyuremxX · Sep 20, 2014 at 01:19 AM ·
destroy object
My object won't destory
using UnityEngine; using System.Collections;
public class Arrow : MonoBehaviour {
public int Direction = 1;
private Vector2 vel = new Vector2(6, 0);
void Update() {
vel = new Vector2(6 * Direction, 0);
rigidbody2D.velocity = vel;
if(Direction == -1) {
transform.rotation = Quaternion.LookRotation(new Vector3(0, 0, -44 + 180));
}else{
transform.rotation = Quaternion.LookRotation(new Vector3(0, 0, -44));
}
}
void OnCollisionEnter2D(Collision2D col) {
if(col.gameObject.tag == "Enemy") {
Enemyhealth eh = col.gameObject.GetComponent<Enemyhealth>();
eh.Health--;
}
if(col.gameObject.tag == "Destroyable") {
Destroy(col.gameObject);
}
Destroy(gameObject);
}
} I tried putting a box collider and it still wont destroy. Plus I tagged it Destroyable.
Comment
Is your enemy health reduce? if it is, you should check the tag name of Destroyable
Your answer
![](https://koobas.hobune.stream/wayback/20220613163352im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Destroy Objects to Load New Scene 3 Answers
[JS] Destroy() just don't work :S 0 Answers
Change Score / On Click Destroy Enemy 1 Answer
Problem deleting object 1 Answer