- Home /
Question by
Nagoshi · Dec 02, 2012 at 10:29 PM ·
collisioncollision detectiondelete
Collision Error: Object won't delete.
In my game, I want object 'a' to be deleted when it comes into contact with object 'b'. I've been having the same problem for a while, and no matter how many different scripts I've tried or how many adjustments I make it's just not working. Which leads me to think it's a really simple fix, but it still eludes me.
My code:
function OnTriggerEnter (other : Collider) {
Destroy(other.gameObject);
}
I have this attached to object 'b'. However when it comes into contact with object 'a' I only get this in the debug area, and no object is deleted, object 'b' just passes through object 'a': MissingFieldException: Field 'UnityEngine.RaycastHit.gameObject' not found.
All objects have rigidbody.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613084841im_/https://answers.unity.com/themes/thub/images/avi.jpg)