0 votes

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:
in Engine by (389 points)
edited by

1 Answer

0 votes

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.

by (7,190 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.