Question by
JuhaJGaming · Dec 20, 2015 at 10:23 AM ·
c#unity 5position
How to get chunks to the right position
I can generate chunks, and perlin noise, but for some reason my terrain doesent position correctly, any help.
chunk cretor code
using UnityEngine; using System.Collections;
public class ChunkCreator : MonoBehaviour {
public GameObject chunck;
public int amount = 5;
public int Size = 16;
public float Scale = 7.00f;
public float ScaleModifier = 5.00f;
public float OffSetHeight = 7f;
public Vector3 Pos = new Vector3 (0, 0, 0);
// Use this for initialization
void Start ()
{
for(float X = transform.position.z; X < amount; X++)
{
Pos.x = X * Size;
for(float Z = transform.position.z; Z < amount; Z++)
{
Pos.z = Z*Size;
GameObject C = Instantiate(chunck, Pos, Quaternion.identity) as GameObject;
C.transform.parent = transform;
C.transform.position = Pos;
Debug.Log("Chunck at:"+Pos);
}
}
foreach (Transform Child in transform) {
Debug.Log ("Real pos" + transform.position);
}
}
}
outputs: Chunk at:0,0 Chunk at:16,0 Chunk at:0,16 Chunk at:16,16 Real Pos: 0,0 Real Pos: 0,0 Real Pos: 0,0 Real Pos: 0,0
Why?
Comment