Is there a way to have my trees randomly sit on the Y axis when they are created by the tree brush?
Is there a script I could attach the the Tree Prefab that would instantiate at a random angle along the Y axis?
I have trees that are very flat and very apparent which direction they face.
do something like this, not tested.
function start () {
gameObject.transform.rotation.y = Random.Range(0.0, 360.0)
}
that should give each tree a random rotation at start,|not: if it gives them all the same random rotation please comment it and i will test the script|, but if you are using the tree tool that places trees i think there is a setting for it.
transform.rotation is a quaternion, you can’t just put euler angles on its x,y,z,w components.
but you can do this:
Vector3 currentRot = this.transform.rotation.eulerAngles; this.transform.rotation = Quaternion.Euler(currentRot.x,Random.Range(0,360),currentRot.z)