Changing Places for Racing Game BGE

This might be a bit noobish to some but how would one go about changing places in a racing game, like once you pass a car, you jump from 4th to 3rd or 2nd to 1rst -and vice versa. I have tried a bunch of different methods but there is always a catch… (I’ll just leave it at that… a catch.)

I’m pretty decent with Python and Logic so you don’t have to lay it all out for me but a good example would be appreciated.

Someone was looking for a solution for a similar problem to yours a few months ago, if I recall. I would just create nodes and place them around the track at even intervals, and then store in each car the number of laps they’ve done and the last node they’ve passed. You could then sort a list of the cars by their nodes and their laps put together to find out what position each one was in.

Im not sure which nodes you are talking about, the only nodes im familiar with are composting nodes that help “visually” enhance your renders. Also I already did laps and figuring out who comes at what place after each laps, that was pretty basic using just 3 sensors. The question is how do I figure out who is in what place at CONSTANT. Like in the the heat of the race, if one car passes you slightly you go down a place and vise versa.

When I said ‘nodes’, I meant invisible sensor objects. If you touch a ‘node’, the car would then set that node to be the ‘current’ node for the car.

Basically, what my idea was was that you could create a path (in Python) for the course, and then check the distance between the previous point in the path and the next point in the path for each car to know exactly how far through the course it is. Then, you can compare that value between cars.

Yes I did something somewhat similar but I plan to have complex race tracks with short cuts, ramps, pick ups, etc. and there in lies the catch. Here is a rough example of the map. But we are on to something here, please bare with me :}


Also Im thinking of doing distance the opposite way around where as in the example it shows how “far” in distance each car is/has gone form the start where as maybe do how “close” in distance each car is to the start.

ALrighty, i’ll check it out. Thanks for the help!

If your into more complex solutions involving Python, check out Martinish’s idea here: http://devlog-martinsh.blogspot.com/2012/07/day5-race-track-coordinate-concept.html