Question by
DevedGames · Mar 12, 2017 at 03:03 PM ·
rotationgameobjecttransform
I want to make a Cube surface
Hello, I want to make a cube with different heightmaps on each Side. And thats what i got. Now i want to wrap this like a Cube, but i am not sure how to do this. If i Rotate it manully each face is much more aweay than before. If i ROtate it around a certain Point with script they are spreat all over the place.
public class Landscape : MonoBehaviour {
public int width = 128;
public int depth = 128;
public int heightScale = 20;
public float detailScale = 25f;
public GameObject cube;
public Transform landscapeMid;
public Transform landscapeLeft;
public Transform landscapeLeft2;
public Transform landscapeRight;
public Transform landscapeTop;
public Transform landscapeBottom;
void Start(){
for (int z = 0; z < depth; z++) {
for (int x = 0; x < width; x++) {
int y = 0;//(int) (Mathf.PerlinNoise(x/detailScale,z/detailScale)*heightScale);
Vector3 blockPos = new Vector3 (x, y, z);
Instantiate (cube, blockPos, Quaternion.identity, landscapeMid);
}
}
for (int z = 0; z < depth; z++) {
for (int x = -width; x < -1; x++) {
int y = 0;//(int) (Mathf.PerlinNoise(x/detailScale,z/detailScale)*heightScale);
Vector3 blockPos = new Vector3 (x, y, z);
Instantiate (cube, blockPos, Quaternion.identity, landscapeLeft);
}
}
for (int z = 0; z < depth; z++) {
for (int x = -(2*width); x < -width-1; x++) {
int y = 0;//(int) (Mathf.PerlinNoise(x/detailScale,z/detailScale)*heightScale);
Vector3 blockPos = new Vector3 (x, y, z);
Instantiate (cube, blockPos, Quaternion.identity, landscapeLeft2);
}
}
for (int z = 0; z < depth; z++) {
for (int x = width; x < (2*width)-1; x++) {
int y = 0;//(int) (Mathf.PerlinNoise(x/detailScale,z/detailScale)*heightScale);
Vector3 blockPos = new Vector3 (x, y, z);
Instantiate (cube, blockPos, Quaternion.identity, landscapeRight);
//landscapeRight.RotateAround (landscapeMid.transform.position, Vector3.forward, 90);
}
}
for (int z = depth+1; z < (2*depth); z++) {
for (int x = 0; x < width; x++) {
int y = 0;//(int) (Mathf.PerlinNoise(x/detailScale,z/detailScale)*heightScale);
Vector3 blockPos = new Vector3 (x, y, z);
Instantiate (cube, blockPos, Quaternion.identity, landscapeTop);
//landscapeTop.RotateAround (new Vector3(width / 2, 0, depth / 2),Vector3.forward,90);
}
}
for (int z = -depth; z < -1; z++) {
for (int x = 0; x < width; x++) {
int y = 0;//(int) (Mathf.PerlinNoise(x/detailScale,z/detailScale)*heightScale);
Vector3 blockPos = new Vector3 (x, y, z);
Instantiate (cube, blockPos, Quaternion.identity, landscapeBottom);
}
}
}
}
And this is my code. Iw ould be very Happy if someone could help me. Ps: Sry for my english.
unbenannt.png
(69.3 kB)
Comment
Your answer
Follow this Question
Related Questions
Problem retrieving transform.position after parent rotation 0 Answers
GameObject not looking at me.. 1 Answer
Clamp without Quaternion? 0 Answers
Canon Ball shooting with Instiate 1 Answer
transform.lookat not working? 0 Answers