Game Development Community

Race position (1st place, 2nd place etc)

by Nicholas Driscoll · in Torque Game Engine · 01/20/2005 (5:43 pm) · 14 replies

Hi, does anyone here know where I can find some code for a GUI system that tells you what place you're in? Like First Place, second Place, etc.

#1
01/20/2005 (5:56 pm)
You could look at the racing mod and see how they handle it.
#2
01/20/2005 (6:47 pm)
Yes, but in starter.racing, I don't see any position GUI. Could someone help me out? Thanks
#3
01/21/2005 (9:31 am)
You can just change the text of one of those text controls that support text formatting, and write the player position on it.
#4
01/21/2005 (2:01 pm)
You have to break this into two tasks:

1. Calculate the race position of each car. If you're just starting out, and you're working with starter.racing the easiest thing to do would be to add code into the checkpoint system. As each car hits a checkpoint, you can calculate the placing for each one based on the number of laps & checkpoint each has completed. This isn't going to be super accurate all of the time unless you have tons of checkpoints, but it will get the job done in the short term.

2. Then you have the display task. You have to send a message from the server to the client to tell it that its place has changed. Then the client can react by setting a text control to the placing, or displaying a bitmap. If you want to go the text control route, look at how the lap counter is handled. If you want to go the bitmap display route, look at how the start race countdown timer is handled.
#5
03/23/2005 (10:50 am)
The Trigger Idea sounds good for simplicity sake, but how would you do it to have constant update of position. Also how would you tell the player is going the wrong way?

both could be done with triggers I suppose but you would not get constant updates. I wonder how hard it would be to implament some kind of path test?

any suggestions?
#6
03/23/2005 (11:37 am)
@Matt
I am making a racing game too. I am still wrestling with the same problem you are.

I am using alot more checkpoints then the racing example uses. I am putting a checkpoint whenever the track changes shape. For example on straightways I don't have many check points, but around turns I have lots of checkpoints. You could calculate the distance of each vehicle to the next checkpoint everytime you run your logic loop.

For determining the wrong way you could calculate direction vector for whatever two check points the vehicle is between. Then determine the angle between the vehicle and the direction vector. Then if the angle is greater then ~80 degrees for a couple seconds. Tell the user they are going the wrong way.

I also plan to use these check points as a way for AI based racers to follow the track.

I haven't fully implemented this idea yet so I can't say it works for sure.

Brian
#7
03/23/2005 (1:30 pm)
Well The good thing about a racer is that the AI will not have to be quite as complex as in other types of games. I plan on using a very simple implamentation of pathfinding. navigating with nodes. I think I may use trig functionality to determine how sharp and smooth different AI will turn around corners. also you need to check to see if you are blocked by other players.

I was thinking very similarly with you on the position functionality though. Still am trying to figure out how other games have done this.
#8
03/23/2005 (1:48 pm)
You should be using a spline path with many points on it to determine position. This gives you a high degree of accuracy. You also would use the spline path to control the AI.
#9
03/23/2005 (2:12 pm)
Thanks for the tip. I have heard of using SPlines and I understand what they are in modeling programs and stuff like that. But how do you implament in Torque? Does Torque have some kind of built in support for Splines?

Thanks in advance

EDIT: also can this be done through the in game Editor?
#10
03/23/2005 (10:38 pm)
I'm pretty sure the Realm Wars demo (one of the Torque demos) includes an AI player running around a spline path. Yes this can be controlled via the editor. In another game using another engine we've done the same thing using a spline path exported from 3DSMax.
#11
03/24/2005 (6:35 am)
Cool!

The Editer is poorly documented right now so what option controls the splines I saw two in the editor under Mission: Path and PathMarker I will mess around with these a little I was just wondering if anyone has some input on when to use which one. Thanks again.
#12
03/24/2005 (10:35 am)
Found out how to make em.
You first have to click on path and name it then in the tree view you alt+click that name to make it so the next object you add are under it. then you start adding PathMarkers.

one question though. I was reading in the forums that some people were talking about a limit to the number of nodes you could have on one path. They said it was limited to 20 because of packet issues over network. does this limitation still exist?
#13
03/24/2005 (1:08 pm)
The limitation is not on the path, it's on the pathCamera, and there are workarounds to it
#14
04/21/2005 (3:53 pm)
Brian McGavin,

You're on the right track with your thinking and it will work. Paths can be created using spline or linear curve, as it adds no relevance to the AI following algorithm. What's important is knowing where the points lie on the path. This algorithm is same as what you see in the fps.starter sample.

One big difference between AI player and AI vehicle paths are in number of points on the path. TGE can store up to ~32 points (forgotten the exact limit). If you need more points than that then you'll need to create multiple paths and be able to switch from one to the next.

As for tracking, have the server keep track of all vehicle positions and distribute (send msg) to clients as to where they are in the race.