Godot Version
4.2
Question
Hi All, doing the ‘learning of Godot’ by remaking Super Cars for fun.
Having trouble understanding why @export var My_Modulate is being shared over all race cars?
-
Old Situation: Before Shader addition. Cars were all different colours via Self_Modulate. All good.
-
New Situation: Shader added to handle a simple sunshine effect to make more 3d looking. Self_Modulate no longer works, as the shader takes control of the image. To fix, Add in colour paramater to visual shader, add in @export var My_Modulate to submit any picked colour to shader (via set_shader_parameter call). All good. Car is a different colour when game is run.
-
Now. New, extra cars added, made Local, but the last car’s My_Modulate colour takes over All the cars.
So, I cannot fathom what is taking control here, or how to remedy it.
All cars have a script, which pulls the colour from My_Modulate, which is set by a colour picker, per ‘each’ car.
Does anyone know what is happening here? Or better yet, how to remedy? I’m lost, as I thought making each car local was enough.
Basic Code in the gdscript node of the car.
@export var My_Modulate: Color = Color(1.0,1.0,1.0,1.0) # Set the car's colour
func _ready():
#-----------------------------------------------------------
# Set Car Colour
#-----------------------------------------------------------
Car_Image.material.set_shader_parameter("Car_Color",My_Modulate)