Children instanced nodes getting the same material

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: 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?

:bust_in_silhouette: Reply From: rogeriodec

Making the material “unique” and turning the option “local to scene” on, it solved the case.

enter image description here

Result:

enter image description here