Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

addCollisonItem(mcAICars);

public function addCollisionItem(mc:MovieClip)
    {
        collisionlist.addItem(mc);
    }


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;
            }

            reduceLife();

            setTimeout(startCar, 500);

        }

Regards, Amit

share|improve this question
    
Posting code snippets and/or screenshots demonstrating the problem would help. –  Tetrad Sep 11 '12 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.

http://en.wikipedia.org/wiki/Numerical_differentiation

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.