Welcome, Guest! Login | Register
Measuring the total distance traveled?
54 Posts

Alright guys, so I'm working on a racing game in 3DRad again. For making more detailed information about certain tracks, I need to measure the distance around the track. I know it'd be some sort of script, but to be honest, I have no idea what it could be?
Created on: 1 month ago
94 Posts

I think if you use the size of the buggy car wheel which is 2mt and count the rotations ... something like that should work

Not sure how to do this in script, but it's a start
Created on: 1 month ago
54 Posts

I figured it out... it was even easier than that.

The way I did it, and keeping it accurate was to use a timer set to a 1 second interval, and add the current vehicle speed (which 3DRad provides in meters per second) onto a variable, which calculated the distance the vehicle has done.

Here's the script code I used to pull it all together.

float min=0;
float sec=0;
float Total=0;
float mil=0;
bool car1=true;
string strMin;
string strSec;
string strMil;
string Time;
int Text = OBJ_22;
int dist;
void Main()
   ///Get our speed from the car
   int spd; 
   spd = IN_44 * 3.6; //For display in kilometers per hour, take the raw meters per second value and multiply by 3.6
   int msSpeed = IN_44; //Raw speed, in meters per second.
   string strEnd = spd;
   strEnd = strEnd + "  ";
   strEnd = strEnd + msSpeed;
   iPrint(strEnd, 0,0, OBJ_22); //Display the speeds

   ///   CONVERT FLOATS TO STRINGS             

   ///   DECLARE TIMES                         
   Time = strMin+"."+strSec+"."+strMil;

   ///   PRINT TIMES                           
   iPrint(Time, -6.5, -8.75, Text);
   ///   EventOnInputs                         
   ///   CAR1                                  

   if (car1 == true) {
      //Normal race timer
      ///This is ALWAYS bound to the player's car as an overall time measurement
      mil += 16.666666666666666666666666666667;
      if (mil >= 1000) {
         mil = 0;
      if (sec >= 1) {
	 //Reset the seconds back to 0.
         sec = 0;
         dist = dist + msSpeed; //Add the current speed onto the total distance value.
   string strf = dist;
   iPrint(strf, 0,5, OBJ_22); //Print the distance completed.
Created on: 1 month ago
94 Posts

sounds interesting, not sure how accurate that would be, but for 3drad, probably good enough.

I found out that a tire with 1 meter radius has a circumference of 6.283mt.. sooo

Then i figured a better way would be to add a custom rigidbody as the wheel ( a block sticks out the side ) which can trigger an eventonlocation attached to the car body, then use script to count the tigger hits per wheel rotation X 6.283mt and that should be pretty accurate..

But your idea mite be the easiest and better way :P  nice going @drninkeo

EDIT: tried out your script, as i figured because your process is timed and relies on 3drad reporting the speed , if the car moves really really slow ( kind of jerky motion ) the distance may not even register movement.

My idea on the other hand should work 100%, unless 3drad fails to register hits over certain speed with the EOL object... which could totally happen...

But still, nice little pice of script you have there 👍
Created on: 1 month ago
Edited on: 1 month ago
54 Posts

True, it does depend on whether the reported speed is greater than zero. But to be fair, a trip meter in an actual car won't report anything if the speedometer reads 0 in that as well 😎

Gathering the distance via wheel angles and height is a little problematic in 3DRad as it reports angles from from +180 to -180 degrees, not the full 0 to 360 like with Unity and Game Maker. 🤔

Created on: 1 month ago
Edited on: 1 month ago
5 Posts

Hi, I think you're over thinking it.

for each loop of script -

Subtract variable (OldLocation) from Current location
Determine magnitude of above
Add magnitude above to Distance Counter
Pass the current location to the variable  (OldLocation)

That way you get the full distance every cycle, you'll need to work out the scale of your world (ie what does 1 magnitude represent)

If you are wanting the track length, and not the car distance travelled, remember it depends what line you take round the course
Using wheels is not accurate as they can spin out (drift etc) without moving the car forward.
Created on: 1 month ago
94 Posts

Funny thing, i too started a new project, this time it's another racing game.

I thought of creating a 8 player slot car game, you know the type kids often buy and setup in the basement.. those are more often 2 to 4 car race tracks, the 8 car if even available would be the expensive version and quite large too.

So anyway, spent a bunch of time recreating the slot track mechanics to steer a car with 4 pieces and joints to connect them.. works pretty well EXCEPT..

A pcar and buggy don't have any settings to allow the front wheels to free float
that would allow the slot device to steer the car.

So i made a custom car with the wheel objects and this seems to work but the basic design doesn't work so well when i use joints to connect the front wheels to the car body that will allow free movement cause the joints just fail to work well and the wheels wobble due to the joint objects.

That aside ( gave up on trying to recreate a mechanical slot device ) cause i also ran into a modeling issue with 3drad and poly surfaces close together and facing opposite to each other ( 3drads modeling tutorials actually say to avoid models likes this cause it can mess up collisions, and yes it does in deed... )

So anyway, figured i'd have to create a fake slotcar track by just using paths for the cars to follow.

So now 3dsmax is being a B**** while trying to create a 8 car slot track, mostly its the texturing process, which i suck at...

But i figured out a process, i think it will work for me.

So now i'm thinking i should know the track distance too, should anyone want to know....

I figure any of the ideas already mentioned should be good enough because in real life car tires can slip and the odometer will never be 100% accurate.

On the other hand, using a 3drad car and configuring it to avoid slippage and to follow the track accurately should be pretty good.

@drninkeo if your trying to measure distance in game on the track during a race, then i can see that's going to be troublesome and i dough will ever be 100% accurate.

PS maybe you could create a satellite system with military grade GPS to track your car and measure distances 🤣
Created on: 2 weeks ago
Edited on: 2 weeks ago
54 Posts

@tinsoldier I think if I ever put that idea into the actual game, it'll only be a representation rather than a true measurement. Just to give players a feeling that they've gotten a fair way
Created on: 2 weeks ago
Or use the advanced reply form here...