- Home /
Tile Generation with collider2D's
I would like to make a bunch of Tiles(on a platformer). However my efforts to make a working collider are manual and thats a hindrance to my workflow and it will ruin the way the game works to some degree(in script and gameplay)... I wanted to know if there was a way to make tile colliders effectively... in script... without the catching corner glitch that Box2D has.
I have 3 choice from what I deducted by myself but they are all pretty bad unless somebody can help me fix them.
Use a bunch of BoxColliders on one game obj... Con; The Corner catching glitch. Possible fix; Make the BoxCollider big enough for more tiles.
Edge Colliders, Using a bunch with a concave edge center where the player will reside. Con; I have no way to figure out the exo and interior of the edge donut that would be a room inside a script. Possible fix; No possible fix without somebody actually having a idea where to start first.
Similar to BoxCollider but with PolyColliders... No Con;No glitch... Same Possible Fix. But I have no idea on how to tackle that like the Edge Collider because complications of actually approximating a shape inside and out easily and accurately.
What the unity team could do... Actually have a function to deduct shape or merge a bunch of shapes into one PolygonCollider2D/EdgeCollider2D.
What is the "corner catching glitch" you are talking about?
As for collider generation, I solved a similar problem by generating a grayscale texture and applying it to a sprite set to not display with a polygon collider on it. Seems the collider shape changes when you set the sprite texture, maybe that would work for you?
Depending on the size of the levels/etc, you could also get the artist to output a grayscale texture.
In Box2D for C++, they had a glitch where if you had a "BoxShape" for each tile in a game. The Top corners would catch on the players feet corners(Unless it was a CircleShape in which case the player would be lurched into the air as if he went off a ramp), But it was random and there was really no nice way to fix it with out changing either the level or the player and entities... Something that "would" only be trivial and easy to solve in Unity.
There is a way to make Unity use grayscale textures for collision in script? because I would be really invested in that feature. And to be square... I'm not using the sprite renderer for various reasons... lighting, shadows, normal maps, and other Advanced 3D stuff... But that's for the world... I'm still using the Sprite Renderer for the player and other stuff.
Answer by Mr.Hal · May 10, 2014 at 12:01 AM
I had to suck it up and use box colliders for every tile, Later on though I'm going to fix this with neighbor checks and stretch the size of the colliders to reduce the amount, Because right now there is too many box colliders but it works fine anyway, I think the unity team may have fixed the glitch, but I do hit phantom bumps when sliding on circles, I compensated with a harsher gravity to reduce the appearances of the bumps. All is well.
Your answer
![](https://koobas.hobune.stream/wayback/20220613143749im_/https://answers.unity.com/themes/thub/images/avi.jpg)