Topic was automatically imported from the old Question2Answer platform.
Asked By
Timofey
extends Spatial
func _ready():
var alphabet = letters.getAlphabet()
for z in range(10):
for x in range(10):
var mesh = load(letters.getLetter(alphabet[randi()%33]))
var meshInstance = MeshInstance.new()
meshInstance.set_mesh(mesh)
meshInstance.position = Vector3(x * 3, 0, z * 3)
add_child(meshInstance)
function letters.getAlphabet give alphabet array
function letters.getLetter give link to letter file with .obj expansion
For Spatials such as meshinstance the “position” is reference using its transform
so change meshInstance.position to meshInstance.global_transform.origin
The correct way though is actually to use the translate() func like meshInstance.translate(Vector3(x * 3, 0, z * 3))
extends Spatial
func _ready():
var alphabet = letters.getAlphabet()
for z in range(10):
for x in range(10):
var mesh = load(letters.getLetter(alphabet[randi()%33]))
var meshInstance = MeshInstance.new()
meshInstance.set_mesh(mesh)
meshInstance.global_transform.origin = Vector3(x * 3, 0, z * 3)
add_child(meshInstance)