I’m looking to set the instances to different colors within my MultiMesh, but no matter what Color I pass the set_instance_color function, my instances display as white and have a color value of (0, 0, 0, 1).
I’ve tried different values for Color, adding the material to the material_override for the MultiMeshInstance3D, different default colors. I’m assuming this is my setup, but can’t figure out what I’m doing wrong. Any help would be greatly appreciated!
I tried this setup as well as this example (this partially worked, but using the same scene I wasn’t able to reproduce the results of simply copy and pasting the example code.)
code snippet:
var multiMesh = MultiMesh.new()
multiMesh.transform_format = MultiMesh.TRANSFORM_3D
multiMesh.instance_count = colors.size()
multiMesh.use_colors = true
var sphereMesh = SphereMesh.new()
var material = StandardMaterial3D.new()
material.vertex_color_use_as_albedo = true
material.albedo_color = Color(1, 1, 1)
sphereMesh.material = material
multiMesh.mesh = sphereMesh
for i in multiMesh.instance_count:
multiMesh.set_instance_color(i, Color(colors[i]))
# example value for colors[i] = "ff7f00"
# I have tried hardcoding values, but nothing changed the color
var instance_position = Vector3(
randf_range(-max_x_distance, max_x_distance),
randf_range(-max_y_distance, max_y_distance),
randf_range(-max_z_distance, max_z_distance)
)
multiMesh.set_instance_transform(i, Transform3D(Basis(), instance_position))
var multiMeshInstance3d = MultiMeshInstance3D.new()
multiMeshInstance3d.multimesh = multiMesh
add_child(multiMeshInstance3d)
Thank you @dbat and @mrcdk ! Looks like the only thing I needed to do was to ensure that I set use_colors = true before setting the instance_count. so simple… but so frustrating lol.