The online racing simulator
Car Detection - Object Detection - LFS_EXTERNAL
Hello,

I'm working on an C# LSgO Based Cruise insim but was thinking...
How do you actually detect car collisions? (Car to Car) Or Object Detection?
And if their is a way to do this could i have an example?

Thanks,

Yoran
Use insim.net mate LFS external is outdated now and i don't think it supports listening for collision packets
You can't do object detection but car detection yes

Look in docs/insim.txt to see what flag you have to add and things like that

Of course with lfs external 1.1.1.7
Seeing what i've done wrong i've started to look upon things. What did come upon me is that i have no sence of coding what so ever. I've added the IS_CON as a event and made a private void for it. Gotten everything to work but then came upon a problem again. Ill show you what i have so far.

private void CON_Contact(Packets.IS_CON CON)
{
try
{
clsConnection Conn = Connections[GetConnIdx(CON.UCID)].PlayerName;
clsConnection Conn2 = Connections[GetConnIdx(Connections[CON.UCID].PlayerNameHit)];
}
catch { }
}

Error:

Error 1 'LFS_External.Packets.IS_CON' does not contain a definition for 'UCID' and no extension method 'UCID' accepting a first argument of type 'LFS_External.Packets.IS_CON' could be found (are you missing a using directive or an assembly reference?) C 1875 65 OC Insim

Any ideas? Thanks!

Yoran
Obviously UCID does not exist! Take a look at how packet works. You can always check Insim.txt at your lfs/docs folder.


struct CarContact // 16 bytes : one car in a contact - two of these in the IS_CON (below)
{
byte PLID;
byte Info; // like Info byte in CompCar (CCI_BLUE / CCI_YELLOW / CCI_LAG)
byte Sp2; // spare
char Steer; // front wheel steer in degrees (right positive)

byte ThrBrk; // high 4 bits : throttle / low 4 bits : brake (0 to 15)
byte CluHan; // high 4 bits : clutch / low 4 bits : handbrake (0 to 15)
byte GearSp; // high 4 bits : gear (15=R) / low 4 bits : spare
byte Speed; // m/s

byte Direction; // car's motion if Speed > 0 : 0 = world y direction, 128 = 180 deg
byte Heading; // direction of forward axis : 0 = world y direction, 128 = 180 deg
char AccelF; // m/s^2 longitudinal acceleration (forward positive)
char AccelR; // m/s^2 lateral acceleration (right positive)

short X; // position (1 metre = 16)
short Y; // position (1 metre = 16)
};

struct IS_CON // CONtact - between two cars (A and B are sorted by PLID)
{
byte Size; // 40
byte Type; // ISP_CON
byte ReqI; // 0
byte Zero;

word SpClose; // high 4 bits : reserved / low 12 bits : closing speed (10 = 1 m/s)
word Time; // looping time stamp (hundredths - time since reset - like TINY_GTH)

CarContact A;
CarContact B;
};

Quote from DarkKostas :Obviously UCID does not exist! Take a look at how packet works. You can always check Insim.txt at your lfs/docs folder.


struct CarContact // 16 bytes : one car in a contact - two of these in the IS_CON (below)
{
byte PLID;
byte Info; // like Info byte in CompCar (CCI_BLUE / CCI_YELLOW / CCI_LAG)
byte Sp2; // spare
char Steer; // front wheel steer in degrees (right positive)

byte ThrBrk; // high 4 bits : throttle / low 4 bits : brake (0 to 15)
byte CluHan; // high 4 bits : clutch / low 4 bits : handbrake (0 to 15)
byte GearSp; // high 4 bits : gear (15=R) / low 4 bits : spare
byte Speed; // m/s

byte Direction; // car's motion if Speed > 0 : 0 = world y direction, 128 = 180 deg
byte Heading; // direction of forward axis : 0 = world y direction, 128 = 180 deg
char AccelF; // m/s^2 longitudinal acceleration (forward positive)
char AccelR; // m/s^2 lateral acceleration (right positive)

short X; // position (1 metre = 16)
short Y; // position (1 metre = 16)
};

struct IS_CON // CONtact - between two cars (A and B are sorted by PLID)
{
byte Size; // 40
byte Type; // ISP_CON
byte ReqI; // 0
byte Zero;

word SpClose; // high 4 bits : reserved / low 12 bits : closing speed (10 = 1 m/s)
word Time; // looping time stamp (hundredths - time since reset - like TINY_GTH)

CarContact A;
CarContact B;
};


Thanks for replying so fast and i already tyed PLID but still. Errors
You need to use CarContact struct. For example

MessageToAll("Player A was in " + CON.A.GearSp + " while B was in " + CON.B.GearSP + " when they crashed eachother.);

I guess you will have to Convert.ToString the 2 byte numbers, but you got the point
That helped ALOT! I've finally figured it out but i think the best for me is to switch over to Insim.net and understand Dizplay source Thanks alot!

FGED GREDG RDFGDR GSFDG