why my color palette being overwrite by other instance?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By potatobanana

why my color being overwrite by other instance?
i instance two player with different color palette , but both of my player follow second player color palette.

why my color being overwrite by other instance?

when i just change modulate color like this
$basic.set_modulate(Color(ColorN(test_color)))it work.
but when i change palette color $basic.material.set_shader_param("pallete",load(PlayerGlobalStat.color_p_d[str(skin_color)].path))

newplayer2 keep overwrite newplayer skin color.

spawn room

var player = preload("res://scene/player/player.tscn")

func _ready() -> void:

	var newplayer = player.instance()
	newplayer.global_position = get_node("slection_Panel/VBoxContainer/character_checkbox/player_slot1/player_slot_pos").global_position
	newplayer.skin_color = str(1)

	var newplayer2 = player.instance()
	newplayer2.global_position = get_node("slection_Panel/VBoxContainer/character_checkbox/player_slot2/player_slot_pos").global_position
	newplayer2.skin_color = str(4)


var skin_color 

func _ready() -> void:
	skin_color= 1

func _process(delta: float) -> void:
:bust_in_silhouette: Reply From: exuin

The players may be different instances, but they still share the same ShaderMaterial resource. Try enabling “Local to Scene” in the ShaderMaterial’s properties and see if that fixes it - you want each ShaderMaterial to be unique.