Skip to main content
gamedev.net
🔒 Locked

Driving around?

Started by shaqdx Dec 17, 2004 at 7:44 PM 6 replies 1.2k views
Original Post
shaqdx
shaqdx
I am implementing a simple 3D racing game, where the track is part of a .bmp file rendered as the landscape. I can control the vehicle but the vehicle can move anywhere within the landscape (away from the track). Does anyone know how I can get the vehicle to stay within this track or if it is too complex to attempt. I have heard stuff like bounding boxes/spheres and path algorithms but these seem long-winded. Aby tips or info would be appreciated. Thanks
Funkymunky
Funkymunky
Yeah I've never done it myself but how about checkpoints along the road, one on either side. That way you just find the two sets of checkpoints that encapsulate the section of road which the car is currently on, interpolate between them to find checkpoints at the cars position, and check if it's between those.
Ravuya
Ravuya
I'd load in the image of the map, and store some kind of "geometry" data for the map that just consists of a bunch of collision boxes drawn fairly close to the road (not perfect, but close enough).

This is the same way they do collisions in games with pre-rendered backgrounds (FF7, Resident Evil...), I believe.
nife
nife
Just to warn you...
Bounding boxes is (in my opinion) one of the easiest ways of detecting collision, but therefore it is also inaccurate for anything other than blocks.
Therefore you should learn it (I didn't thought of it as beeing diffult to master).
Killers don't end up in jailThey end up on a high-score!
markr
markr
The obvious thing is to not require the cars to stay on the track, but make it advantageous to the player to do so.

Ensure that the drag off the track is sufficiently high, it's attractive to stay on it most of the time.

Place checkpoints around the track that the player must pass to have a lap counted .

Mark
ajas95
ajas95
I think a really simple, robust method would be to use conical capsules -- Where you just have a segment defined by 2 pts and a maximum distance at each point and interpolate that distance down the length of the segment to create a cone-shape capped by a sphere at each end. Then if you make a loop using a bunch of these connected segments, the interior of which is your collision geometery, it should work out pretty well and be super simple...

you just have to remember that parts of the the different capsules can overlap and different parts of the car can be in different capsules and it'd still be a valid position. This also makes it easy to avoid the really nasty case where the car drives into a narrow wedge-shaped piece of the track (obviously you can still do it... you'd just have to be a damn fool :)

Try it out on paper. Draw a connected loop of points. Draw a circle around each one, and connect the consecutive circles by their tangents... This sounds interesting, maybe I'll try to knock out a fast OBB-conical_capsule test later on.
Motorherp
Motorherp
You could encode on-track and off-track data in the bmp. Then shoot rays downwards from the car extremeties and where they intersect the terrain check that texel to see if its on-track or off-track. Not sure how exactly you'd go about implementing this since its just an idea that popped in my head but I'm just trying to offer you alternatives.
[size="1"] [size="4"]:: SHMUP-DEV ::
Ravuya
Ravuya
Quote:
Original post by markr
The obvious thing is to not require the cars to stay on the track, but make it advantageous to the player to do so.

Ensure that the drag off the track is sufficiently high, it's attractive to stay on it most of the time.

Place checkpoints around the track that the player must pass to have a lap counted .

Mark


You'd still need to do the same kind of collision to determine whether or not they're off the end of the track, but yes, I agree with your design philosophy. That way you could hide little things on the track far off the beaten path.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.