Rotating trees

This commit is contained in:
nlitkowski 2021-12-19 23:54:01 +01:00
parent 7ed2f43346
commit 3bcb8efaff

View File

@ -122,22 +122,13 @@ public class Main : MonoBehaviour
{
for (int k = 0; k < rowsNumber * gridShiftZ; k += gridShiftZ)
{
// vector for rotating 90 deg
Vector3 rotationVectorRotateX = new Vector3(-90, Random.Range(0.0f, 360.0f), 0);
Vector3 rotationVector = new Vector3(0, Random.Range(0.0f, 360.0f), 0);
randomShiftX = random.Next(0, maxShiftValue);
randomShiftZ = random.Next(0, maxShiftValue);
GameObject tree = SelectRandomTree();
// trees other than AS12_4 have to be rotated 90 deg
if (tree.name != "AS12_4")
{
renderedTrees.Add(Instantiate(tree, new Vector3(i + positionShift_x + randomShiftX, 0, k + positionShift_z + randomShiftZ), Quaternion.Euler(rotationVector)));
}
else
{
renderedTrees.Add(Instantiate(tree, new Vector3(i + positionShift_x + randomShiftX, 0, k + positionShift_z + randomShiftZ), Quaternion.Euler(rotationVectorRotateX)));
}
renderedTrees.Add(Instantiate(tree, new Vector3(i + positionShift_x + randomShiftX, 0, k + positionShift_z + randomShiftZ), Quaternion.Euler(rotationVector)));
}
}