Unlink material from instanced scenes

kryzmakkryzmak Posts: 109Member

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?

Best Answers

  • kryzmakkryzmak Posts: 109
    Accepted 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:

  • TwistedTwiglegTwistedTwigleg Posts: 2,468
    Accepted Answer

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

Answers

  • kryzmakkryzmak Posts: 109Member
    Accepted 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: 109Member
    edited February 2019

    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: 2,468Admin
    Accepted Answer

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

  • kryzmakkryzmak Posts: 109Member

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

    var unique_mat = $Mesh.get_surface_material(0).duplicate()
    $Mesh.set_surface_material(0, unique_mat)
    

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file