One reason why you might get this error is that your material_override
property is null
. i.e there is no material setup in there. To do this, try:
material_override = SpatialMaterial.new()
material_override.albedo_texture = texture
If it's not null and you have a ShaderMaterial
instead, try:
material_override.set_param("albedo_texture", texture)
Note: I see you create your texture manually. This might not work once the game is exported. Is that because you expect players to provide image files?
Otherwise, you could simply write this:
var texture = load(actual_path)