Collision Lab

What's Happening

The Web Driver's collision API allows you to ask the question,

"If I were to move my object from it's current position to there, would it hit something?"

If your object hit something, a WTCollisionInfo object is returned from the method call. If not, nothing is returned. You can use this object to gather information about the collision.

But enough of the boring stuff! Take a look at the scene above. There are two pigs in the scene. Think of the pink one as the "source" and the blue one as the "destination." (Refer to the direction of the red arrow.) You can drag each of them with the mouse.

Imagine that the pink pig is an object in your game. You want to move your object to the position denoted by the blue pig, but first you want to check for a collision. If a collision is found, the location of the impact is shown with a red X. Furthermore, the collision normal (the line perpendicular to the surface against which the pig collided) is shown with a green arrow. Note that the pigs will not collide against each other.

You can specify the detail of the collision checks. "High" detail gives you polygon-perfect collision, while "low" detail uses the bounding boxes of objects in the scene.

Key Methods Used

WTGroup::checkCollision, WTCollisionInfo::getNewPosition, WTCollisionInfo::getImpactNormal

Points to Remember