So, I am creating terrain :
Code: Select all
foreach (BPTerrain CurrentTerrain in Terrains) {
var Data = new float[CurrentTerrain.Width, CurrentTerrain.Height];
for (int i = 0; i < CurrentTerrain.Height; i++) {
for (int j = 0; j < CurrentTerrain.Width; j++) {
Data[j, i] = CurrentTerrain.HeightData[i * CurrentTerrain.Width + j];
}
}
Terrain GroundShape = new Terrain(Data,
new AffineTransform((Vector3)(Position)CurrentTerrain.LocalScale,
Quaternion.CreateFromYawPitchRoll(
CurrentTerrain.Rotation.Y,
CurrentTerrain.Rotation.X,
CurrentTerrain.Rotation.Z),
(Vector3)(Position)CurrentTerrain.Center));
GroundShape.Shape.QuadTriangleOrganization = QuadTriangleOrganization.BottomRightUpperLeft;
Space.Add(GroundShape);
DebugModelsDrawer.Add(GroundShape);
}
![Image](http://s12.postimg.org/hettjpn7h/terrain1.png)
Don't care about box at the left side. Just look on box at the top - this is CharacterController (or I guess character controller's entity) bounding box, I draw it using BoundingBoxDrawer. Here is the code for Character controller and space creation :
Code: Select all
WorldSpace = new Space();
WorldSpace.ForceUpdater.Gravity = new BEPUutilities.Vector3(0, -9.81f, 0);
BoxDrawer = new BoundingBoxDrawer(this);
cc = new CharacterController(new Vector3(40, 12, 40), CharacterHeight, CharacterHeight / 2.0f, CharacterWidth, 0.1f, 10);
WorldSpace.Add(cc);
![Image](http://s18.postimg.org/wuy4rfr3d/terrain2.png)
Part of the character went througth terrain. If after it I start to move character at any direction it slowly (depends on speed) will go above terrain like it supposed to be. I think what it is some kind of physical properties issue, like denisty, friction or something else. I am right? How can I fix this and set terrain as solid ground?
Thanks.