- Home /
Does a collider have to be attached to a GameObject?
For my game, I am using Graphics.DrawMesh to create the chunks in a Minecraft style game. This is very helpful because removing the overhead from GameObjects has reduced the time to generate chunks by a noticeable measure. However, I am running into an issue with physics. Right now, the chunk creates a gameObject, attaches a MeshCollider, and gets a reference to the collider. I assign the mesh once the player is close enough to the chunk to interact with the blocks and the collider is enabled/disabled based on the player's proximity to the chunk.
However, I am wondering: is there a function that would allow me to arbitrarily place a collider without a GameObject, much like Graphics.DrawMesh? If not, then I what I am currently doing will still work (even if it isn't the most elegant solution).
Answer by hexagonius · Oct 03, 2017 at 09:17 PM
No, you cannot have colliders without GameObjects. Everything other than renderable geometry that exists in a world is a gameobject with its Transform.
What you could do is just move as many colliders with rigidbodies aroud to where the current important chuck is. This way you only need a couple, if not just one to interact with. If it's blocks, just use boxcolliders, they're more optimized.