I had a quick question for the community. I haven’t done anything with 2D in Unity but I was curious what kind of support it had for collision detection and whether it was limited to physics.
The reason I ask is that a couple of years ago I implemented 2D intersection tests for XNA. It works only for convex shapes as it implements the Separating Axis Theorem.
If this is the type of thing that you guys think people would need for Unity I’d port my code over and put it up on the Asset Store as a free asset.
I may go ahead and do it then. I actually probably wouldn’t do a full blown collision detection system but rather something that could be repurposed into one. I was thinking something more light-weight. Really, the SAT (Separating Axis Theorem) only works for Convex Shapes… I think it can also be used for 3D Polygons as well, I’ve just never implemented it for more than just 2D shapes… but essentially I thought people might be interested in a script that allowed intersect testing between arbitrary 2D shapes without the overhead of being a full-blown collision system.
I’d have to put some thought into how to implement it. XNA didn’t provide as many of the nice built-in things that Unity does so for the system to work, the user actually supplied vector2’s (min and max for rectangles, or lists of vector2’s for n-gons). The nice thing is that it doesn’t limit you to axis-aligned elements. SAT is actually interesting and works by essentially using an imaginary axis parallel to each face and projecting all points from both shapes to that axis check for overlap. The checks actually perform quicker for shapes that intersect because as soon as it finds an overlap between the sets of points it knows there is an intersect and can exit.