- Home /
Destroy gameObject leaves behind collider?
I am using a Sphere collider as a trigger to prompt the player to interact with an object. The parent object has a script to handle the destroy function and several child objects - neither the parent or the child objects have colliders, they have AudioSources, but no Rigidbody. The Sphere collider is a child object and has a script attached. That script instructs the parent script to destroy itself and this is working. Sure enough, the object disappears from the scene when the right conditions are met.
The problem is, it is leaving behind something invisible which is acting as a collider so the player character can't walk into the (now) empty space where the object formerly existed.
Can anyone give me an idea what is happening here?
The code for the removal function is as follows:
public class FFS_RemoveMe : MonoBehaviour {
public float removeTime = 0.0f;
public AudioClip briiing;
public GUIText displayText;
// Use this for initialization
void Start () {
}
public void destroyMe(){
gameObject.audio.PlayOneShot(briiing);
Destroy (gameObject, removeTime);
}
void Destroy(){
}
}
The calling script is:
faulty.SendMessage("destroyMe");
faulty is a public gameObject type which is set to the parent gameObject in the Inspector.
Answer by robeth · Jul 12, 2012 at 11:08 AM
Strange. Have you tried to inspect hierarchy & inspector tab to ensure the game object fully disappeared? Check whether there is an object has collider in that "empty space"
Thanks for the tip - I checked and the object disappears from the Hierarchy but still there is something blocking the way.
I also just moved the object in the scene just in case there was another object interfering: same result.
how about the other game object? maybe they have collider filling that empty space. if it isn't, i don't have any other clue :|
Thanks Robeth, I just checked that, I moved the game object to a completely different location and it still behaved the same way. I am going to check the player characters locomotion scripts to see if there is anything cuckoo there.
We have managed to fix it - there was a texture associated with the script which had a collider but was not parented to the actual object we were destroying. It was set to not be rendered after use which was why it was invisible but still present. Sorry for the headache this gave anyone....