Sign in to follow this  

best way to check checkpoints and distance

This topic is 2062 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

hi all!
i have a question about my racing game..
I need to understand the position (in percentage or by distance) of the road driven and also check some checkpoints..
In my mind the checkpoints maybe solved by distance (checkpoint #1 at 12,3% for example)

what's the best way (and fast to calculate) to do this?

I've tried with bezier, but is hard and slow find a tangent point...
actually I've some points that represents the centerline of the road

thanks in advance [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Share this post


Link to post
Share on other sites
I'd totally give up the idea of distance and just have a collidable sensor signal me when the player passes through them.
But perhaps you also want to give the player an estimation of the distance to the next checkpoint. Is that the case?

Share this post


Link to post
Share on other sites
If we're talking a race track... just have the checkpoints represented by a plane. Then the checkpoint is "hit" when the player's vehicle intersects the checkpoint plane.

If you also want to represent the % around the track the person is at, then simply have a series of line segments that represent the track. Then the nearest point on the line segments is where they are (completion wise) and calculating the total % complete is trivial. Should take care to handle the case of skipping a checkpoint though when calcuating said %

Share this post


Link to post
Share on other sites
[quote name='Krohm' timestamp='1334997043' post='4933465']
I'd totally give up the idea of distance and just have a collidable sensor signal me when the player passes through them.
But perhaps you also want to give the player an estimation of the distance to the next checkpoint. Is that the case?
[/quote]
thanks for this info.. interesting

[quote name='Washu' timestamp='1334997045' post='4933466']
If we're talking a race track... just have the checkpoints represented by a plane. Then the checkpoint is "hit" when the player's vehicle intersects the checkpoint plane.

If you also want to represent the % around the track the person is at, then simply have a series of line segments that represent the track. Then the nearest point on the line segments is where they are (completion wise) and calculating the total % complete is trivial. Should take care to handle the case of skipping a checkpoint though when calcuating said %
[/quote]

thank you, so for example a simple line between my 2 points and calculate by tangent the nearest point... have you got some example to read?

thanks again

Share this post


Link to post
Share on other sites
You can google up on finding the nearest point on a line to another point. Then you simply calculate that value for all line segments and the value with the smallest distance is the closets one along the entire set of line segments representing the race track.

Alternatively, since you know which line segment they started on (the start of the race was in that segment, you can simply calculate the nearest point on the current line segment, the previous line segment, and the next line segment.

Since the line segments should be in order (from start -> next -> next -> next -> finish) you can simply take the point you find and the sum of the distances of each preceding line segment all over the total of the sum of the length of all line segments to get the % completion.

Share this post


Link to post
Share on other sites

This topic is 2062 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this