I was casually trying to fix something related to player coloring. When a player joins, they should be either red, green, blue or yellow. They are neon yellow no matter what. I have a toon shader, the albedo value in the shader is changed only once. I have no idea how to fix it and it removes all of the shading.
player.gd
# initializer values
func _ready() -> void:
player_color = game_autoload.get_free_color()
animtree.set("parameters/walkdirblend/scale", 1.0)
animtree.set("parameters/movement/blend_amount", 0.0)
var auth := is_multiplayer_authority()
camera.current = auth
print(auth, name)
set_process_unhandled_input(auth)
set_physics_process(auth)
if is_multiplayer_authority():
$bean/Armature/Skeleton3D/Plane_001.set_layer_mask_value(1, false)
$bean/Armature/Skeleton3D/Plane_001.set_layer_mask_value(2, true)
camera.set_cull_mask_value(2, false)
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
print($bean/Armature/Skeleton3D/Plane_001.get_surface_override_material(1))
$bean/Armature/Skeleton3D/Plane_001.get_surface_override_material(1).set("shader_parameter/albedo", player_color)
# game controls
game_autoload.gd
extends Node
var reserved_colors = []
var free_colors = [Color(255, 0, 0),Color(255, 255, 0.0),Color(0.0, 255, 0.0),Color(0.0, 0.0, 255)]
# networking
func get_free_color():
for i in range(len(free_colors)):
if free_colors[i] not in reserved_colors:
var resco = free_colors[i]
free_colors.remove_at(i)
reserved_colors.append(resco)
return resco
Thanks! Please request clarification if I was unclear.