The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 3 of 3

Thread: Keeping a vehicle on the ground.

  1. #1

    Keeping a vehicle on the ground.

    I have an interesting question. How do would you go about keeping a vehicle on the ground as it moves across a bitmap?

    Heres my current method, it works... However, it has it's strange bugs... Like, when the vehicle comes to a cliff it tends to pop up into the air. Which, I am going to add yet another workaround for...

    Anyone know how it's done in flash biking games like this?

    *Explanation: findGroundFine is a function that uses about 3-10 hittests to find the land edge by hit testing the bitmap. The points move closer together the higher the vehicle is rotated to keep them in place in the front and back of the wheels.

    Theres a few bits of workaround code... If the vehicle is falling off a cliff, it doesn't automatically snap into position on the land.

                    //Keep buggy on ground
                    var leftFirstWheelY = global.findGroundFine(x-(10-(Math.abs(rotation)/16)), y);
                    var rightFirstWheelY = global.findGroundFine(x-(5-(Math.abs(rotation)/16)), y);
                    var leftFirstWheelX = x-(10-(Math.abs(rotation)/16));
                    var rightFirstWheelX = x-(5-(Math.abs(rotation)/16));
                    var rightSecondWheelY = global.findGroundFine(x+(10-(Math.abs(rotation)/16)), y);
                    var leftSecondWheelY = global.findGroundFine(x+(5-(Math.abs(rotation)/16)), y);
                    var rightSecondWheelX = x+(10-(Math.abs(rotation)/16));
                    var leftSecondWheelX = x+(5-(Math.abs(rotation)/16));
                    var groundPointY = (leftFirstWheelY + rightFirstWheelY + rightSecondWheelY + leftSecondWheelY) / 4;
                    if (groundPointY > y && Math.abs(groundPointY - y) > 10) {
                        velY ++;
                    } else if (groundPointY < x && Math.abs(groundPointY - y) > 10) {
                    } else {
                        velY = 0;
                        y = groundPointY;
                        var buggyRotation = rotate2Point(Math.atan2(((leftFirstWheelY + rightFirstWheelY)/2)-((rightSecondWheelY + leftSecondWheelY)/2), ((leftFirstWheelX + rightFirstWheelX)/2)-((rightSecondWheelX + leftSecondWheelX)/2)));
                        rotation = buggyRotation+180;
    Last edited by DesignerMichael; July 5th, 2008 at 02:24 AM.

  2. #2
    is this problem solved?

  3. #3
    Nope... Thinking about using fisix or something like that... Actually, thats flex... Damn!
    Last edited by DesignerMichael; July 7th, 2008 at 02:50 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012