Godot Version
4.3-stable
Question
There is three instances of a scene of healing bottle in my scene, each has unique shader material for liquid inside,
(In code, during _ready(), I do)
fill.mesh.material = fill.mesh.material.duplicate()
fill.mesh.material.resource_local_to_scene = true;
fill.mesh.material.set_shader_parameter("fill_amount", amount)
(where fill is
@export var fill : MeshInstance3D;
)
But, when user interacts with one bottle (through calling a method in collider of raycast), all three shaders are affected during function call
func interact(body):
if amount >= min:
emit_target_signal();
amount = amount - 0.1;
fill.mesh.material.set_shader_parameter("fill_amount", amount);
but factually “interact(body)” is called only for one of bottles, not for three, so there seem to be no issue with interaction script, only that shader materials are tied to each other for some reason.
Have I not actually make material unique, have missed something? Changing sequence of code in _ready() does not help, for all answers on similar issue I have found, code with “resource_local_to_scene = true” & “material = material.duplicate()” seems to be working, not for me
pic 1, before interaction
pic 2, after interaction
pic 3, scene tree containing objects in question