using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class treeGen : MonoBehaviour
{
public GameObject[] thetrees;
public float xpos;
public float zpos;
public float treeNum;
void Start()
{
GameObject[].transform.Rotate(90f, 0f, 0f, Space.Self);
StartCoroutine(treeGenerator());
}
IEnumerator treeGenerator()
{
while (treeNum < 10)
{
xpos = Random.Range(-7, 8);
zpos = Random.Range(-9, 9);
int randomIndex = Random.Range(0, thetrees.Length);
GameObject clone = Instantiate(thetrees[randomIndex], new Vector3(xpos, 2.211817f, zpos), Quaternion.identity);
yield return new WaitForSeconds(1f);//waits for one second to spawn
//Instantiate(thetrees[randomIndex].transform.Rotate(90, 0, 0, Space.Self));
treeNum += 1;
}
}
}
Not sure what you’re trying to do with this code: GameObject[].transform.Rotate(90f, 0f, 0f, Space.Self);But it’s not valid syntax. What were you trying to do?
You could do this with a loop, or just rotate the clones inside yourwhile loop around line 25… But why not just fix your prefabs? Your clones are on their sides because your prefabs are on their sides. Just go edit the prefabs in the prefab editor and fix their orientation.