Can somebody explain how the collision detection works for race tracks in games like need for speed or wipeout?
This consists of wrapping game entities in a non-rotated (thus axis-aligned) box and checking the positions of these boxes in the 3D coordinate space to see if they are overlapping. The axis-aligned constraint is there because of performance reasons.
One of the simpler forms of collision detection is between two rectangles that are axis aligned — meaning no rotation. The algorithm works by ensuring there is no gap between any of the 4 sides of the rectangles. Any gap means a collision does not exist. Note: Another example without Canvas or external libraries.
drive isn't necessarily a racing game, more a driving game, but when it comes to actual racing, few games have as good a damage model as Dirt Rally. The way the bodywork bends and disintegrates, the wheels bend out of alignment and fall off and the more realistic way the cars pick up damage is all mightily impressive.
I found a well illustrated article describing collision detection between the cars in a racing game. It also has a general description of the concepts of collision detection.
For the track collision detection you could use something like the color map approach discussed here. Essentially you just draw a map containing your track in a distinct color. Then you read the color at the projected position of the car from the map - if it's the tracks color you have a collision.
I found another seemingly good article describing basic 2D collision detection algorithms.
HTH.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With