Hi,
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:
extends MultiMeshInstance
export(int) var treeScale = 5
func _ready():
self.scale = Vector3(treeScale, treeScale, treeScale)
func updatePositions(posArray):
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)
self.multimesh.set_instance_transform(i, transformation)
I have been messing around with transformation.rotated but sometimes it rotates the trees off of my mesh.
How should I implement rotation?
Thanks.