Jump to content
  • Advertisement
Sign in to follow this  
sjf

rand race track help

This topic is 4833 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My aim for this week is to randomly generate a race track. The track is just going to be simple – flat on the x, z axis. I would very much like it to configure into a loop style track. Each of the walls would be just a simple line segment defined by a x1, z1, x2 and z2. The track should have walls on both sides. So now, where to start? Ideas, suggestions and more importantly sample code (hint, hint). TIA.

Share this post


Link to post
Share on other sites
Advertisement
you can have a look at this

basically, it's like drawing a circle. Calculate points in a circular fashion, just make the radius for each point random.

I use a catmul rom spline to make it smooth.

it's very basic, and the spline will go weird around tight bends.

for the collision, I take the point on the centre of the track the closest to the car, and if the car deviate more than the width of the track from there, collision.

Share this post


Link to post
Share on other sites
Sorry, but can you explain "catmul rom spline". I looked at your code, but still have no idea. TIA

Share this post


Link to post
Share on other sites
Cool, I did a google and found some good items. They helped alot!

Next step collision detection. Oliii I did like your idea 'bout collision detection, However, I just don't seem to follow "cTrack::GetClosestPath" in your example. Do you have an English version (i.e. without code) to just explain what's going on? Thanks very much.

Share this post


Link to post
Share on other sites
in english.

track portions are made of 3 paralle segments (which are samples from the catmul rom spline interpolation). The edges, and one running in the middle. Track has a constant half-witdh (something like 5 meters. so 10 meters width).

basically, find the segment and point on segment in the middle the closest to the car. once found, calculate the distance of the car to that closest point. If distance > track half-width, collision.

By caching the segment from frame to frame, finding the closest segment is quick (except the first time). Then I take the ten-or-so segments before and after that segment, and find the closest.

It's all quite approximative, but works OK in most cases.

The only 'difficult' bit is the segment-point distance calculation.

Share this post


Link to post
Share on other sites
BTW, The original idea for the collision system was to use the idea for some sort of sci-fi racing. You'd have a central powerline in the middle, and speedbike racing. The closer you are to the centre of powerline, the more power the vehicle gets. So when you stray off the line, you loose drive, which can be mildly useful for coasting around corners and shaving off speed, but damaging in straight or high speed corners. The idea of racing would be to stay as close to follow the powerline as close as possible to keep the power going. And obviously shove your opponnents off the precious power source.

Also, that leads to cool energy powerups, like shields, energy binder that pulls you towards the centre of the track, ect...

Just an idea of a game that's been running in circle in my head.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!