0 votes

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 (57 points)

1 Answer

0 votes

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 (57 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 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 webmaster@godotengine.org with your username.