Collision Detection
Using Ray Casting with Shapes
Feb 15th
Back in July, we looked at how to use Ray Casting for collision detection. We also learned how to use the Separation of Axis Theorem. I recently had a request for a way to use the Shapes we created here with the Ray Casting method. First, lets do a quick review of the shape classes.
The SAT Shape ClassesThe BaseShape class is the class that all shapes extend. It has the basic properties, position, rotation and scale as well as the transform matrix that transforms the vertices based on rotation, scale and position. It has getters and setters for each of those More >
Detecting Collisions with SAT
Nov 28th
Today we will finally be detecting a collision with SAT. We know how SAT works, we’ve built classes to work with SAT, now we can use all of this to detect a real, live collision!
Using the classes we created last time, this is quite simple. First create a shape:
var shape1:Polygon = Polygon.rectangle(530, 30, new Vector2D(270, 360));
It’s a simple polygon created using the static function of the rectangle class. Now we need another shape to collide with:
var shape2:Polygon = Polygon.rectangle(20, 50, new Vector2D(260, 350));
And now we need to test for a collision:
var data:CollisionData = Collision.testShapes(shape1, shape2);
When you run this, you should More >
Using the Separation of Axis Theorem
Nov 22nd
A few months ago, I posted on the separation of axis theorem. You can learn all about SAT and how it works here. What that post failed to do was use the SAT. We will explore using SAT for collision detection in this post.
In the post on SAT, we created the code to detect collisions, however use of the code was not covered. (A download of all the classes used in the post is available at the bottom).
The Shape ClassesThe easiest way to use SAT uses Shape classes. There are two shape classes we will need, the Circle and the More >
AS3 2D Ray Casting For Collision Detection
Jul 8th
Ray casting is a technique usually used in 3D worlds (often for rendering). Ray casting is exactly what it implies a ray is cast from a start point until it hits something (or a max length, so the computer doesn’t die). Ray casting in 2D is great for collision detections, especially fast-moving objects (bullets).
In this post, we will learn the basics of ray casting in 2D, then we will apply it to bullets in a simple environment.
A ray is just a line. It has a start point and an end point. In order to use this method effectively, we need More >
SAT in Action
May 22nd
In a previous post, I explained the Separation of Axis Theorem. Now it’s time to see SAT in action.
Click on a shape to move it. It both will turn red when they are touching. The shapes will turn black again when they are not colliding. Use the drop down lists to change the shapes.
Separation of Axis Theorem (SAT) for Collision Detection
May 19th
The separating line and axis form a 90 degree angle.
The Separation of Axis Theorem(SAT) is a technique to test whether two convex polygons are colliding. The SAT theorem: “given two convex shapes, there exists a line onto which their projections will be separate if and only if they are not intersecting.” The line where the shapes have disjoint projections is called the separating axis.
A separating line is the line that can be drawn between the two shapes, without touching either shape. Because flash is 2D, I will only be showing this method for 2D, but it can be done in 3D(in 3D, More >




