Hi I tried with this simple C# script to automatically rotate trees placed by the terrain tree paint tool. I created two 3 prefabs and then added them to tree palette. But seems that when the tree is used alongside with terrain the script is not runned. This script only works when placing trees manually. That’s a bit disappointing.
using UnityEngine;
using System.Collections;
public class RotatingTree : MonoBehaviour {
Vector3 Rotation;
// Use this for initialization
void Awake() {
gameObject.transform.Rotate(0,Random.Range(0,360),0);
}
void Start () {
Rotation = new Vector3(0,Random.Range(0,360),0);
}
// Update is called once per frame
void Update () {
//gameObject.transform.Rotate(Rotation); //test
gameObject.transform.Rotate(0,Random.Range(0,360),0);
}
}
seems that nether “Awake” function is called in this case. Having many trees all rotated the same manner is not very good looking.