Says that set_shader_param does not exist

Godot Version

Player:

@onready var sprite : Sprite2D = $Sprite2D
@onready var shader : ShaderMaterial = $Sprite2D.material

func darkness(running : bool) -> void:
	if invis and !running:
		shader.set_shader_param("darkness", true)
	else:
		shader.set_shader_param("darkness", false)
	return
shader_type canvas_item;

uniform bool darkness = false;

void fragment() {
	if (darkness){
		COLOR = COLOR * vec4(0.4, 0.4, 0.4, 0.75);
	}
}

Question

For some reason I can't use the set_shader_param since it doesn't exist for the item.

Because it’s set_shader_parameter and not set_shader_param

2 Likes

This is the old syntax from Godot 3. It’s a good idea to always check the documentation for the correct version of Godot, because many incompatible changes were introduced between 3 and 4.

alright I try to remember that for next time.