I'm trying to add walls to my 3D game. I created a wall entity and added model array
public Walls()
{
modelArray = new Model[10];
}
public void Initialize(ContentManager contentManager)
{
for (int i = 0; i < modelArray.Length; i++)
{
rnd = new Random();
sidesWall = rnd.Next(-4, 4);
forwardWall = rnd.Next(-8, 0);
modelArray[i] = contentManager.Load<Model>("wall");
}
}
Draw method:
public void Draw(Camera camera)
{
foreach (Model m in modelArray)
{
foreach (ModelMesh mesh in m.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = true;
effect.World = GetWorldMatrix();
effect.View = camera.ViewMatrix;
effect.Projection = camera.ProjectionMatrix;
}
mesh.Draw();
}
}
}
It doesn't work and it shows only one wall.
How can I make it work?