3D Racing Game Question
3D Racing Game Question
I was thinking about making a 3D racing game. But my only concern is how I will make the ai racers follow the road? Or how do I go about creating point destinations on a 3D terrain? Maybe there's a better way that I have not thought of? Any ideas or tips would be great.
www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
Re: 3D Racing Game Question
Set way points along the road and connect them with spline/bezier curves or simple direct lines (you may need many waypoints for straight lines to look good).
Or you could create the road on a fine mesh and apply the a-star path finding algo. That way bots can drive out of cornets in which they got pushed by themself.
I wouldn't worry about any 3D-stuff except in the displaying section of your code.
Just assume the terrain is flat and your cars are flat. Only 2D collision is needed (exceptions to me made at tunnel crossings and jumps)
Then you just display the Mesh at z = TerrainHeight - CarHeight and rotate it by the angle of the road inclination.
Or you could create the road on a fine mesh and apply the a-star path finding algo. That way bots can drive out of cornets in which they got pushed by themself.
I wouldn't worry about any 3D-stuff except in the displaying section of your code.
Just assume the terrain is flat and your cars are flat. Only 2D collision is needed (exceptions to me made at tunnel crossings and jumps)
Then you just display the Mesh at z = TerrainHeight - CarHeight and rotate it by the angle of the road inclination.
Re: 3D Racing Game Question
What I did in a 2d racing game: I had "way points" that were elements in a linked list, the way point was a structure that had a "close enough" value, and a list of 4 possible next points. A car would head to the selected way point, when the distance between the car and the point was less than the close enough value (otherwise they would sometimes go in circles trying to hit the point), it would randomly select a valid point in the list of next points belonging to the current point. That way the cars didn't drive "single file".
Re: 3D Racing Game Question
Hi J.Baker,
I would use NO bezier but only ref points,
NEEDED DATA:
predefined points:
NEW REF. POINTS:
ROAD_left_new_ref (X_left_new, Y_left_new, Z_left_new)
ROAD_right_new_ref(X_right_new, Y_right_new, Z_right_new)
OLD REF. POINTS:
ROAD_left_old_ref (X_left_old, Y_left_old, Z_left_old)
ROAD_right_old_ref(X_right_old, Y_right_old, Z_right_old)
to precalculate:
CAR_old (X_old, Y_old, Z_old) = OLD (previous) center point of the road
CAR_new (X_new, Y_new, Z_new) = NEW (next) center point of the road
And so you can also calculate the CAR rotation
CAR_pitch
CAR_yaw
CAR_roll
If you like to use detection of other CARS,
U must use LEFT limit and RIGHT limit of the road to pass the cars.
GOOD luck, this seems not a simple software.
Greetings,
Marc
I would use NO bezier but only ref points,
NEEDED DATA:
predefined points:
NEW REF. POINTS:
ROAD_left_new_ref (X_left_new, Y_left_new, Z_left_new)
ROAD_right_new_ref(X_right_new, Y_right_new, Z_right_new)
OLD REF. POINTS:
ROAD_left_old_ref (X_left_old, Y_left_old, Z_left_old)
ROAD_right_old_ref(X_right_old, Y_right_old, Z_right_old)
to precalculate:
CAR_old (X_old, Y_old, Z_old) = OLD (previous) center point of the road
CAR_new (X_new, Y_new, Z_new) = NEW (next) center point of the road
And so you can also calculate the CAR rotation
CAR_pitch
CAR_yaw
CAR_roll
If you like to use detection of other CARS,
U must use LEFT limit and RIGHT limit of the road to pass the cars.
GOOD luck, this seems not a simple software.
Greetings,
Marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...
Re: 3D Racing Game Question
If you're open to PureGDK, a lot of the complex stuff for games is built in, like terrain and collision:
http://forum.thegamecreators.com/?m=for ... 77817&b=38
It's a port of the DarkBasic Professional engine and is compatible with any of its native plugins, free and commercial. There's literally thousands of useful code snippets on the DBP forum that can help you get on your feet quickly.
There's also example code included with the DarkPhysics library for vehicle collision and physics so you won't have to calculate it on your own.
http://forum.thegamecreators.com/?m=for ... 77817&b=38
It's a port of the DarkBasic Professional engine and is compatible with any of its native plugins, free and commercial. There's literally thousands of useful code snippets on the DBP forum that can help you get on your feet quickly.
There's also example code included with the DarkPhysics library for vehicle collision and physics so you won't have to calculate it on your own.
Re: 3D Racing Game Question
Another idea would be a recorder which saves your player's input. Then you simply playback your recorded drive for the a.i.
Repeat
PureBasic
ForEver
PureBasic
ForEver
Re: 3D Racing Game Question
Interesting idea! Could even move the player slowly and push a keyboard key when you want a point to be recorded. Thanks!A.D. wrote:Another idea would be a recorder which saves your player's input. Then you simply playback your recorded drive for the a.i.
www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
Re: 3D Racing Game Question
I thought you were initially asking how the AI will adhere to the road through gravity or physics. To get the AI to follow the road itself, what you need is A* pathfinding.
There is a tutorial here:
http://www.policyalmanac.org/games/aStarTutorial.htm
Sample code from TGC forum (there are a lot of them here):
http://forum.thegamecreators.com/?m=for ... =11137&b=6
http://forum.thegamecreators.com/?m=for ... =10057&b=6
PureGDK is also compatible with DarkAI which would give you everything you need:
http://www.thegamecreators.com/?m=view_product&id=2024

There is a tutorial here:
http://www.policyalmanac.org/games/aStarTutorial.htm
Sample code from TGC forum (there are a lot of them here):
http://forum.thegamecreators.com/?m=for ... =11137&b=6
http://forum.thegamecreators.com/?m=for ... =10057&b=6
PureGDK is also compatible with DarkAI which would give you everything you need:
http://www.thegamecreators.com/?m=view_product&id=2024

Re: 3D Racing Game Question
I like A* path finding, with quad trees, but in a racing game, your cars are trying to get from point A to point A again. How would you force A* to do laps?
- Rook Zimbabwe
- Addict
- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
Re: 3D Racing Game Question
You have multiple points... i suggest a minimum of 12 for an oval track and more for more curves!GBeebe wrote:I like A* path finding, with quad trees, but in a racing game, your cars are trying to get from point A to point A again. How would you force A* to do laps?
-
- Addict
- Posts: 2344
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
Re: 3D Racing Game Question
You'll just build a invisible wall for the pathfinding at the start line, set the startpoint a bit after it and the end point a bit before it and connect them when A* found a solution.GBeebe wrote:I like A* path finding, with quad trees, but in a racing game, your cars are trying to get from point A to point A again. How would you force A* to do laps?
bye,
Daniel
Daniel
Re: 3D Racing Game Question
A little hint http://www.purebasic.fr/english/viewtop ... 16&t=47387J. Baker wrote:I was thinking about making a 3D racing game. But my only concern is how I will make the ai racers follow the road? Or how do I go about creating point destinations on a 3D terrain? Maybe there's a better way that I have not thought of? Any ideas or tips would be great.
Best regards.
Guimauve
Re: 3D Racing Game Question
Thanks!Guimauve wrote:A little hint http://www.purebasic.fr/english/viewtop ... 16&t=47387J. Baker wrote:I was thinking about making a 3D racing game. But my only concern is how I will make the ai racers follow the road? Or how do I go about creating point destinations on a 3D terrain? Maybe there's a better way that I have not thought of? Any ideas or tips would be great.
Best regards.
Guimauve

www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.