What is the node path to a shader parameter? (tween animation)

Godot Version

4.3 mono

Question

tween_fade.tween_property(self, "shader_parameter/Tint", end_color, anim_duration)

This is the line of code that's giving me the error. You might have already seen the problem with it, but I can't find how to write the path to the shader ;-( I tried copying its path from the context menu, but it didn't work either

Capitalization matters; should that be Tint or tint?

Nope. Neither worked. Either one gives me the error message. I’ll copy it down below, maybe it helps

E 0:00:02:0467   MightyGhostingEffect.gd:19 @ _startGhost(): The tweened property "shader_parameter/Tint" does not exist in object "MightyGhost:<Sprite2D#37648074149>".
  <C++ Error>    Condition "!prop_valid" is true. Returning: nullptr
  <C++ Source>   scene/animation/tween.cpp:110 @ tween_property()
  <Stack Trace>  MightyGhostingEffect.gd:19 @ _startGhost()
                 MightyGhostingEffect.gd:10 @ _ready()
                 Player.gd:125 @ _on_ghosting_timer_timeout()

I’m assuming self is the node with the material? ‘shader_parameter’ is defined in the material. You can either set the tweener object or update the property string:

# the object is the material
tween_fade.tween_property(material, "shader_parameter/Tint", end_color, anim_duration)

# use 'material:' to access its properties
tween_fade.tween_property(self, "material:shader_parameter/Tint", end_color, anim_duration)

Finally, you could also tween the set_shader_parameter method:

tween_fade.tween_method(func(tint: Color): material.set_shader_parameter("Tint", tint), start_color, end_color, anim_duration)
3 Likes