The online racing simulator
Help me create a simple drifting insim - i'll host a server for you free 1 month
Hello. Im trying to do a C# drifting insim, and so far I've managed to make a insim that connects to the server and so on. Now I just missing the "program" that the insim is going to do, and I need some help, because I don't know to much about the coding in C#(sharp) 2008.

So If someone out there want's to give a helping hand, I'll offering to host a server for them in 1 month for free on a fiber-optic 10Mbit / 10Mbit internet connection that runs 24 / 7.

The program I want some help with is a program that shows your driftscore in a insim button, and has a angle-meter ( that shows the angle of your car when drifting) which is something similar to the insim that W.S have.

If this sounds interesting, please send me a PM.


Greetings LeifOlav™fun
Sorry. Can a moderator move it for me, please?
#4 - sun
if you want to make a button in C# then i suggest you need my help ?
Quote from sun :if you want to make a button in C# then i suggest you need my help ?

erm...haven't you just made a thread asking why your button isn't working? I don't run into the nearest university and start lecturing Japanese because I can say "konnichiwa"...
#6 - sun
err, yes but thtas my km..... i think nobody can help me, lol
Quote from sun :i think nobody can help me

im inclined to say indeed but im afraid taa will sit on me till i apologize to him for doing this sort of thing here
He's taking the mickey, as there is no such thing as "an insim". Insim is part of LFS.

I'll let you off though, because I'm nice. I once had flowers near my name
Quote from Shotglass :im inclined to say indeed but im afraid taa will sit on me till i apologize to him for doing this sort of thing here

I've given out my warning for the day, I'm afraid
I was thinking about the angle meter. I have no idea how to calculate the angle ... Any ideas?
Compare the heading of travel with the orientation of the body. A little maths will get you the angular difference between the two.
I've got the understanding of the angle meter now, but anyone know how the calculate the drifting score ( speed and angle of the car? ) - like in the lfs lapper?
The LFSLapper code is open source, so you could have look at how they've done it yourself.
Quote from Bob Smith :Compare the heading of travel with the orientation of the body. A little maths will get you the angular difference between the two.

The maths is the problem..
Quote from DarkTimes :The LFSLapper code is open source, so you could have look at how they've done it yourself.

Yea, I've already done, but I dont completely understand it


public class MCI
{
public int numOfPlayers;
public DefCompCar[] compCar = new DefCompCar[8];

public MCI(byte[] packet)
{
numOfPlayers = pakGetByte( packet, 3 );
int offsetStartPlayer = 4;
int lengthPlayer = 28;

for (int i = 0; i < System.Math.Min(8,numOfPlayers); i++)
{
compCar[i] = new DefCompCar();

compCar[i].node =pakGetWord(packet, offsetStartPlayer + i * lengthPlayer + 0);
compCar[i].lap = pakGetWord(packet, offsetStartPlayer + i * lengthPlayer + 2);

compCar[i].PLID = pakGetByte( packet, offsetStartPlayer + i * lengthPlayer + 4 );
compCar[i].x = pakGetInt( packet, offsetStartPlayer + i * lengthPlayer + 8);
compCar[i].y = pakGetInt( packet, offsetStartPlayer + i * lengthPlayer + 12);
compCar[i].z = pakGetInt( packet, offsetStartPlayer + i * lengthPlayer + 16);
compCar[i].speed = pakGetWord( packet, offsetStartPlayer + i * lengthPlayer + 20);
compCar[i].direction = pakGetWord( packet, offsetStartPlayer + i * lengthPlayer + 22);
compCar[i].heading = pakGetWord( packet, offsetStartPlayer + i * lengthPlayer + 24);
compCar[i].angvel = pakGetShort(packet, offsetStartPlayer + i * lengthPlayer + 26);
// System.Console.WriteLine("ID:{0} x:{1} y:{2} z:{3} speed:{4} direction:{5} heading:{6} angvel:{7}", PLID, x, y, z, speed, direction, heading, angvel);

// if(debug)System.Console.WriteLine("{0:F2}m {1:F2}m {2:F2}m {3:F2}km/h {4:F2} {5:F2} {6:F2}", xm, ym, zm, spm, dirm, headm, angm);
}
}
}

If this is the correct code I don't understand how the calculate it
Nope, what you're looking at there is just the code to unpack the compcar structure and make it more usable.
I had a quick look through the lapper src, and I think the drift calculation code is in the Players.cs file. Look for the UpdateState method, there's alot of code in there that mentions drifting, angle, velocity, drift-score etc..
Yup, I found it. Thanks for helping.

But after a while trying to understand this code, I figured out that it's still to hard for me to understand. So can anyone help me (over msn or whatever) make a code for drifting angle and drifting score? I don't wanna spend so many hours trying to understand all of this, so If anyone could help I would be grateful.
I need a complete theory , what divide by what etc. , im noob in maths
To be honest the code is there in Lapper in the UpdateState method. First it gets the absolute angle of the car, using the direction and heading, then it checks to see if the absolute angle is between the minimum and maximum allowable angle (EG the car is actually drifting), then it updates the drift score. We're really only taking about the first 10 or so lines of the method. It's all there.
Isn't it just find the difference between heading and direction, and make it positive if it's negative? That's what I used before and it worked

You can then do any sort of calculation on the resulting angle to make a score out of it, it depends on what you want
thanks , but i got it now ...
(Direction / Heading) * 182 = angle
Quote from Nadeo4441 :thanks , but i got it now ...
(Direction / Heading) * 182 = angle

Cool, any idea how i can easily 'let my insim know' what Heading is?
Is there any math included like above in the Quote?
1

FGED GREDG RDFGDR GSFDG