- Home /
How to handle the ground [mesh?] of an infinitely large world?
I've made a little prototype game that uses perlin noise to make very large maps. My game has a top-down 2d orthographic perspective, so very little of the total map is visible at any given time.
I wasn't sure the best way to handle this huge world, so I simply made a bunch of tiles (~400) that fill my screen and I have them change their textures as I run around. I never create/destroy any tiles, I just have them recheck the underlying map data every time they move. I'm not sure if that's silly or not, but it appears to work fine.
What I'm looking for is a way to have the ground elevation change, and make these "tiles" look more sophisticated. I can change the camera to isometric, but what next?
Can I alter/move a mesh as my player runs around?
How can I maintain tile-like behavior within a mesh?
How would I get started?
Could I make a mountain, or would I have to fake it a bit?
Would I want to texture 2 triangles (an approximate square) of the mesh at a time?
Here's an old picture of Ultima Online showing some minor deformations/bumps of the ground where the sand meets rocky path, also see the rocky stuff. This game also had ramps in it, though it failed to ever convey a sense of going up a mountain (it felt more like going into a mountain, due to the lack of legit elevation change). I'd love to get a similar or better effect.
Thanks!
Answer by Oliver Eberlei · Jun 18, 2011 at 10:21 AM
Regardless of how you would get your height data into the game (I don't have enough information how you store your terrainData) you can change the vertices of each tile like so.
This assumes all your tiles have only 4 vertices.
Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
for( int i = 0; i < 4; ++i )
{
vertices[i] = new Vector3(vertices[i].x, heightOfTheTerrain[i], vertices[i].y);
}
mesh.vertices = vertices;
To create mountainranges its probably easiest to create mountain tiles in your 3d application and swap your default terrain tiles for mountain tiles if neccessary.
Thanks, that's the exact type of thing that I was looking for!