# Bending of track in a racing game

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

## Recommended Posts

Hi!

I am trying to create a small racing game in which the track would be modeled using a BSpline curve for the path's center line and directional vectors to define the 'bending' of the track at each point.

My problem is that I don't know how to calculate the correct bending / slope of the curve, in such a way that it would be optimal or at least visually nice for a car to 'bend in the corner'.

My idea was to use the direction of the 2nd derivatives of the curve, however while this approach looks fine for most of the track, there are points in which the 2nd derivative makes sharp 'twists' / very quick 180 degree flips. I also read about 'knots' of bsplines, but I don't know if such 'twist' in 2nd derivatives is a knot or knots are something else.

Can you tell me that using a BSpline:
1. How could I calculate a visually nice bending of a track for a racing game?
2. Is it possible to do this by using some simple calculations of centripertal force / gravity?
3. Is it possible to do this by using 1st, 2nd and 3rd derivatives of the BSpline curve?

I am not looking for the 'physically correct' bending angle for the track, I would just like to create something which is visually pleasing in a simple game.

I am using a framework which has a built-in class for BSpline, including support for 1st, 2nd and 3rd derivatives of the curve.

Thank you!

##### Share on other sites

The surface normal vector of the track should be roughly opposite of whatever forces are acting on the player's car

f = mass * gravity + centripetal force

surface normal =  -f / | f |

centripetal force = bspline 2nd derivative * speed of the player * mass

You'll probably need to do some smoothing so that the twists in the 2nd derivative don't make the track look chopped up.

• 12
• 9
• 17
• 13
• 11