Unlink material from instanced scenes

kryzmakkryzmak Posts: 84Member

I have a template object from which I instance multiple objects. The object template has a standard spatial material set.
When I now change for just one of this objects the albedo of that spatial material via script at game runtime, all other objects of same type with that linked material will also change their albedo color.
I understand, that Godot internally references on just one material blueprint but how could I make this single change unique without ending making for every single instanced object a complete new material?


  • kryzmakkryzmak Posts: 84Member
    Answer ✓

    Ok nevermind, should have been looked just a bit better. For those who also do not know how to solve this:

    After instancing, mark the instance as "Editable Children", then head to the material and click on the little down arrow to make it unique:

  • kryzmakkryzmak Posts: 84Member
    edited February 11

    And I am ready for another question: How can I do this via code? I can get to the Material via $Mesh.get_surface_material(0) but what follows?

  • TwistedTwiglegTwistedTwigleg Posts: 1,043Admin
    Answer ✓

    I could be wrong, but I think you need to use the duplicate function.

  • kryzmakkryzmak Posts: 84Member

    @TwistedTwigleg Yep, you are great. That worked fine:

    var unique_mat = $Mesh.get_surface_material(0).duplicate()
    $Mesh.set_surface_material(0, unique_mat)
Sign In or Register to comment.