Hey guys!
First time here, so sorry for being a greenhorn.
I have created a simple game in Unity wich generates Terrain procedurally and uses a simple form of chunck loading.
Here’s some pictures:
![alt text][1]
![alt text][2]
But, there is a problem. The generated terrain is based on Perlin Noise. When I get to the World-Coordinates x = 0 or z = 0 (Even though I have Shifting Origin, those coordinates are the absoulte ones!) the terrain is basically mirrored:
![alt text][3]
What can I do against that? Looking forward to answers!
Here is the code:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ProceduralTerrain : MonoBehaviour {
int id;
Mesh mesh;
Vector3[] vertices;
Vector3[] normals;
Vector2 old_tile_coordinate = new Vector2(10,10);
// Use this for initialization
void Start () {
for (int i = 0; i < 26; i++)
{
if (name == TileManager.tile*.name)*
{
id = i;
}
}
//RecalculateTerrain();
}
public void RecalculateTerrain()
{
mesh = GetComponent().mesh;
vertices = mesh.vertices;
normals = mesh.normals;
for (int i = 0; i < vertices.Length; i++)
{
float real_x = (float)TileManager.tile_coordinate[id].x * 100.0f + vertices_.x * 10.0f;
float real_z = (float)TileManager.tile_coordinate[id].y * 100.0f + vertices.z * 10.0f;_
float height = (Mathf.PerlinNoise(real_x * 0.003f * Mathf.PI, real_z * 0.003f * Mathf.PI) - 0.5f) * 5.0f;
vertices*.y = height;*
}
mesh.vertices = vertices;
mesh.RecalculateBounds();
mesh.RecalculateNormals();
GetComponent().sharedMesh = null;
GetComponent().sharedMesh = mesh;
}
* // Update is called once per frame*
* void Update () {*
if (old_tile_coordinate != TileManager.tile_coordinate[id])
{
RecalculateTerrain();
}
old_tile_coordinate = TileManager.tile_coordinate[id];
* }*
}
*[1]: http://i.imgur.com/mWbpvOw.jpg*_
[2]: http://i.imgur.com/pjzyUUB.jpg*_
_[3]: http://i.imgur.com/AVsZZPJ.jpg*_