Calling Space.Update() is too slow, maybe it's because scene mesh has 3934 faces.
My game not really need to update space.
It has one scene and some players, I have already implemented collision limit using ConvexCast before, find contact point, and limit player's position.
Players are always moving, so when players move, I need to update theirs entity position, so RayCast and ConvexCast can hit them.
Problem is that when I update entity's position,its position data really changed, but its collision data doesn't seems like, RayCast still can't hit it.
Code: Select all
Box playerEntity = new Box(new BEPUutilities.Vector3(999, 999, 999), 1, 1, 1, 1);
space.Add(playerEntity);
playerEntity.Position = new BEPUutilities.Vector3(0, 0, 0);
RayCastResult rayCastResult;
BEPUutilities.Ray ray = new BEPUutilities.Ray();
ray.Position = new BEPUutilities.Vector3(0, 10, 0);
ray.Direction = BEPUutilities.Vector3.Down;
float distance = 1000;
if (space.RayCast(ray, distance, out rayCastResult))
{
}
else
{
//Not Hit
}
But If I update space, it will work.
Code: Select all
Box playerEntity = new Box(new BEPUutilities.Vector3(999, 999, 999), 1, 1, 1, 1);
space.Add(playerEntity);
playerEntity.Position = new BEPUutilities.Vector3(0, 0, 0);
space.Update(0.1f);
RayCastResult rayCastResult;
BEPUutilities.Ray ray = new BEPUutilities.Ray();
ray.Position = new BEPUutilities.Vector3(0, 10, 0);
ray.Direction = BEPUutilities.Vector3.Down;
float distance = 1000;
if (space.RayCast(ray, distance, out rayCastResult))
{
//Hit
}
else
{
}