Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | rogeriodec |
I have “Cilindro” as a RigidBody with 2 children: Cilindro_Mesh and a CollisionShape.
I’m creating 5 instances and I want to change the color of each instance.
But the color is on the child “Cilindro_Mesh”.
So I have this code:
extends Spatial
var cilindro = preload("res://Cilindro.tscn")
func _ready():
var g = $Grupo_Cilindros
for i in 5:
var c = cilindro.instance()
c.translate(Vector3(i*3,1,0))
c.get_node("Cilindro_Mesh").material_override.albedo_color = Color8(i*50,0,0)
g.add_child(c,true)
But all children are getting the same color.
How can I fix this?