So I have a tree mesh attached to my multimesh, and I have a exported variable to pick how many trees I run.
When my game runs, a landscape mesh is generated and positions to place trees are picked by raycasting random positions over the mesh. After I have the positions, I loop over the instances in my mesh and translate the trees to the appropriate position.
Now, I want to add a random rotation to my trees so that they son't all look the same.
This is my multimesh code:
export(int) var treeScale = 5
self.scale = Vector3(treeScale, treeScale, treeScale)
print("Update tree positions")
for i in self.multimesh.instance_count:
var position = posArray[i]
position.y -= 2
position /= treeScale
var rotation = rand_range(0, PI * 2)
var transformation = Transform(Basis(), position)
I have been messing around with transformation.rotated but sometimes it rotates the trees off of my mesh.
How should I implement rotation?