I am making a car parking game in flash and AS3 wherein I drive my car along with other AI traffic cars moving along a specified path using Guidelines.

I am using CDK for collision detection.

The collision detection works fine with few AI cars, but doesn't seems to be working as required for few AI cars.

When an AI car is moving on a path in a straight line it works fine.... but when the AI Car turns at 90 degress..... my car goes into the AI car (Overlapping) and it hits at the center of that AI car and then collision is Detected.... .....

I made a New path and used a new Sprite for AI car... but still the problem pursues....

I have attached the png of collision. https://dl.dropbox.com/u/53998590/Collision.png

The AI traffic comes from Top Left corner and moves down towards bottom right corner.

The problem persist with this kind of movement.

when I change the movement of same AI cars from bottom right corner and moves up to top left corner then the problem does not exist.

I had used CDK for collision detection.

my code is as follows.


public function addCollisionItem(mc:MovieClip)

var collArray:Array;
collArray = collisionFunction();

if (collArray.length > 0 && isCarCollided==false && game.stopCar ==false)
            trace("Car Collided");
            isCarCollided = true;
            game.stopCar = true;
            if (speed >= 2) {
                speed = 1.5;
            speed = -speed;
            if (accelerate && isCarCollided)
                //reverse = false;
                speed = -1.5;
                //  return;
            else if (reverse && isCarCollided)
                //accelerate = false;
                speed = 2;
                //  return;
            setTimeout(startCar, 500);

Regards, Amit

  • \$\begingroup\$ Posting code snippets and/or screenshots demonstrating the problem would help. \$\endgroup\$
    – Tetrad
    Sep 11, 2012 at 15:08

1 Answer 1


Then you must be using a linear-collision-detection. You should add a 5-point derivative system to find the next speed&position of the next iteration for both X and Y directions.



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .