Changing material of child scene?

Godot Version

4.2.2 Stable (Win64)

Question

I have a voxel scene in my game. It has a MeshInstance3D child to draw it.
On the root of the voxel (a Node3D), how can I make a material property to change the material of the mesh? This is to make variants of the voxel scene that are different colors without copying the whole voxel into each one (if I instantiate a scene, changes will sync to everything. If I copy, everything has to be updated)

(new to Godot, sorry if I’m missing something)

If you are in the editor you can right click the scene and select “editable children”

You can also make a “new inherited scene” for variants of a scene, by right clicking the tscn/gltf file in the filesystem panel.

In scripts you can use node paths to get the MeshInstance3D by name.

The editable children button lets me access the MeshInstance, but only if I make RedVoxel have its own root node and then instantiate voxel.tscn under it.

An inherited scene almost works, except the error that also showed up when I tried to change the Mesh from the editable children mode.
“This resource belongs to a scene that was instantiated or inherited. Changes to it must be made in the original scene.”

godot, the whole point is to make a change to it.
I also tried a solution I saw in this thread, but MeshInstance3D doesn’t have a material property (the editor option to change the material shows up, but doesn’t actually change anything in the rendering).

You can add a material override to the inherited scene

I’m sorry… A what?
Better question:
How?
Where would I start with that?

2024-07-29-155202_279x427_scrot

These three options (or more surface material overrides) can help in this scenario.

Thank you!
Do I need to do anything other than mark that as the solution?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.