This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

I have "Cilindro" as a RigidBody with 2 children: CilindroMesh 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?

in Engine by (60 points)

1 Answer

+1 vote

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

enter image description here
enter image description here

Result:

enter image description here

by (60 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.