I moved to a new URL! Check it out!

Dev Log: Polygon Collisions

Dev Log: Polygon Collisions
I never thought I'd be able to get polygon collisions working in Otter but this past week I managed to jam out a quick prototype of an overlapping polygon test that seems to be working.

Image


Probably not the most exciting image in the world, but it's pretty dang cool to me. I found this tutorial on the Separating Axis Theorem. This tutorial specifically has some great images, and amazing pseudocode with explanations that allowed me to finally understand what the hell to do. I still don't understand some things, like what exactly projecting a vector onto an axis means, but right now I think I have the core of it working.

I'll be working on getting the PolygonCollider integrated into Otter properly over the next few days. That means I'll have to get it working with each other Collider type which shouldn't be too crazy, but we'll see if I end up getting stumped by something!

Comments

Jake Albano
Jake Albano
Whoooa this is crazy talk :O

I guess I don't have any excuse to keep procrastinating on it myself now.
Posted October 6th 2014 11:33 AM
Bret Hudson
Bret Hudson
I implemented SAT into a game I was working on earlier this year, and found the tutorial you're using super helpful as well. However, there's another tutorial I fell in love with which has over a dozen little interactive Flash applications that show the objects colliding, their projections, and other information related to overlapping areas. Super neat!

Tutorial: http://www.metanetsoftware.com/technique/tutorialA.html

Also, as for projection onto an axis, the easiest way to think of it is to imagine you're taking the shadow of a vector, so to say. So if you had a diagonal line, the projection onto the x-axis would be its shadow on the ground if the line was directly above it.
Posted October 6th 2014 4:34 PM
Bret Hudson
Bret Hudson
*light was directly above it (If you have admin tools feel free to fix that in the previous comment)
Posted October 6th 2014 4:36 PM
Rusty Moyher
Rusty Moyher
Very cool IMO
Posted October 7th 2014 12:34 PM
Kyle
Kyle
Bret: Yeah the metanet tutorial is kind of the holy grail but I can never make heads or tails of it. Without seeing actual example code I'm totally lost. Although these days I actually can see what is happening in that metanet tutorial... I think I first found that tutorial in like 2006 and it melted my mind. I think the shadow thing makes sense, I haven't looked into the math too deeply x_x

Jacob: Feel free to just copy pasta my code if you want, haha!

Rusty: <3
Posted October 8th 2014 5:56 PM
new comment!

Post your comment!

Name
Email
Comment