- Home /
Colliders become 'semi-enabled' when moved
It appears that when I move a game object with a disabled collider, the collider becomes 'semi-enabled'. What I mean by 'semi-enabled' is that while running the game, after disabling and moving it, the inspector correctly says that it is disabled, but the Gizmo tool shows a dull green collider mesh (instead of the usual bright green), and as far as I can tell, it behaves as if it is enabled. Rigid bodies will interact with it as if it were enabled. Is this a bug or is it the intended behavior? If the latter, why?
Are you using a script to disable / enable / move the collider? If so please post the code so we can better understand and better help :)
I'm not using a script. In my testing, I boiled the issue down to its pure essence. You can try it yourself. $$anonymous$$ake something with a collider. Disable the collider in the inspector (at run time or before). $$anonymous$$ove the object at run time (either in the inspector or in a script). And then, even though the collider says it is still disabled, things will collide with it.
O$$anonymous$$, for whatever reason, it isn't still happening when I 'boil it down to the essence'. However, it is still happening in the original scenario. I have a mesh that I generate at run time in the shape of a section of terrain. I attach a mesh collider. If I drop a rigid body ball on it, it behaves as expected. If I disabled the collider on the terrain and drop a ball, it falls straight through, as expected. However, if I then move the terrain a little bit in the inspector, and then drop another ball, it will behave as if the collider were enabled.
It may be worth pointing out that, normally, when you disable a collider at run time, it goes dark green when you have the Gizmo thingy enabled. With this terrain mesh collider, it just goes completely invisible when you disable the collider. But when you move it, it suddenly appears in dark green. And more confusingly, it behaves as if it were light green (enabled).
Anyone got any ideas?
I've encountered this as well, when I had a plane infront of my fps cam it had mesh collider disabled until my character moved and the plane did as well then the collider activated and my character could walk on air, which was a cool enough effect but not what I wanted at all.
Answer by DemianT · May 23, 2013 at 05:28 PM
I submitted a bug report to Unity and they said that it is indeed a bug and they have sent it for resolution with the developers.
Answer by iTris777 · Jul 01, 2013 at 01:54 PM
It is still true on Unity 4.1.4f on Mac OS X, for mesh colliders.
Answer by StevoKeano · Nov 04, 2015 at 08:09 AM
Saw something similiar on a Unity3d 5.2 generated Android 6.0 app.
Have 2 terrains, 1 enabled at a time; but, the collider is still active and the Airplane landed in the air. over the grand canyon... Included a line to disable collider too; but, not yet tested. Code below.
private void SetActiveTerrain(GameObject terrain)
{
terrain.GetComponent<Terrain>().enabled = true;
terrain.GetComponent<Collider>().enabled = true;
if (terrain.name != "Valles Marineris"){
VallesMarineris.GetComponent<Collider>().enabled = false;
VallesMarineris.GetComponent<Terrain>().enabled = false;
}
if (terrain.name != "GrandCanyon"){
GrandCanyon.GetComponent<Collider>().enabled = false;
GrandCanyon.GetComponent<Terrain>().enabled = false;
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613102446im_/https://answers.unity.com/themes/thub/images/avi.jpg)