First of all, I'm very impressed with BEPUphysics. It works exceedingly well, is staggeringly easy to integrate and is nicely documented. And the multithreading is a breeze, very well thought out. Top stuff.
I'm getting good results from the SimpleCharacterController included in the demo source. I had to make a small fix to it: it appears that surface normals are not being rotated by the supporting entity's transform. In my test level this meant that the player could walk on crates (Box entities) if they had the default orientation, but otherwise the player would "get stuck" as the controller thought the character was on a slope.
I changed the end of the FindSupport() method from:
Code: Select all
supportNormal.Normalize();
return supportDistance < float.MaxValue;
Code: Select all
supportNormal.Normalize();
if (supportDistance < float.MaxValue)
{
supportNormal = Vector3.Transform(supportNormal, supportEntity.InternalOrientationMatrix);
return true;
}
return false;
Code: Select all
if (candidate.RayTest(rayOrigin, Vector3.Down, maximumDistance, false, out hitLocation, out hitNormal, out distance))
{
...
}
Code: Select all
var offset = Body.Radius;
var delta = Body.Radius / 5f;
for (var ox = -offset; ox <= offset; ox += delta)
{
for (var oz = -offset; oz <= offset; oz += delta)
{
var newRayOrigin = new Vector3(rayOrigin.X + ox, rayOrigin.Y, rayOrigin.Z + oz);
if (candidate.RayTest(newRayOrigin, Vector3.Down, maximumDistance, false, out hitLocation, out hitNormal, out distance))
{
...
}
}
}
I have a couple of issues. As background, my level consists of a StaticTriangleGroup built from a TriangleMesh, as recommended in the getting started guide (I didn't have much success using kinematic boxes as physics slowed to a crawl once there were a few hundred of them). The level is pretty much square and axis aligned, so generally the player is walking on a grid made up of pairs of 2m square triangles. The player is 0.5m across and 1m tall and crates are 0.5m cubes. As noted I'm using the SimpleCharacterController to move the player around and jump.
The first issue is that when the player is pushing crates around the level, the ground seems to be "bumpy"; crates seem to flip over periodically, I'm guessing as they cross triangle boundaries, even though their neighbours have the same normal, are the same size in a regular grid, etc. This didn't happen when using kinematic boxes. Is there anything I can do to prevent this?
The second issue is that jumping (at 5m/sec) seems to quite frequently get the player "stuck" in the ceiling, which is a grid of 2m triangles just like the floor. It only happens about one time in four, depending on where on the grid I jump. I'm guessing it's related to the floor bumpiness problem, something to do with the handling of triangle meshes. Is there any way I can avoid this?
All the best,
-eg.