RayCast wheels
RayCast wheels
I'm having a problem with ray cast wheel when trying to actually use a physical body for the wheel... The problem is the body will be detected by the raycast and supporting the vehicle and there is no way to tell the wheel to exclude certain objects afaik. The reason I want a body for the wheel is to detect collision from other sources such as well you guessed, bullets
Re: RayCast wheels
Use the raycast method that includes all of the hits:
Then iterate through all of the hit entities, finding the hit with the lowest time (toi) that is not your wheel.
Then use x to reference which it hit.
Sorry for the weird indentation on the code snippets, I copied it from a peice of code inside a method.
Code: Select all
List<Entity> hitE = new List<Entity>();
List<Vector3> hitL = new List<Vector3>();
List<Vector3> hitN = new List<Vector3>();
List<float> hitT = new List<float>();
space.rayCast(Cam.position, Cam.Unproject(), 20f, false, hitE, hitL, hitN, hitT);
Code: Select all
x = -1;
for (int y = 0; y < hitE.Count; y++)
{
if (hitE[y] != wheel)
{
if (x != -1)
{
if (hitT[y] < hitT[x])
{
x = y;
}
}
else
{
x = y;
}
}
}
Code: Select all
if (x != -1)
{//Do stuff here!
}
Sorry for the weird indentation on the code snippets, I copied it from a peice of code inside a method.
i has multiple toes
Re: RayCast wheels
Maybe I wasnt clear, but I mean the ray cast performed "under the hood" by the BEPYphysics.RayCastWheel
Re: RayCast wheels
I believe the wheel will ignore entities that have their isDetector flag equal to true, but I'm currently away from the code. Detectors will still generate contacts and such (and throw collision events), but will not undergo collision response. Wheel support filtering could use some improvement. This laptop is about to run out of batteries so I'll check back later.
Re: RayCast wheels
Well then, I have no idea! Never used the wheels included with physics.
i has multiple toes