Godot Version
Godot 4.6.2
Question
I am currently trying to create a customisation system for the NPCs in my game, and I’m having trouble getting their clothes to change colour. He is the code I have in the ready function trying to set their pants to black:
skinMat = Material.new()
skinMat.albedo_texture = skinTex
bottomMat = Material.new()
bottomMat.albedo_texture = clothTex
bottomMat.albedo_color = Color(0,0,0)
skinTex and clothTex are set outside of the ready function as such:
@onready var skinTex = preload("res://Textures/NPCs/skinTexture.png")
@onready var clothTex = preload("res://Textures/NPCs/clothTexture.png")
The material is then applied as such:
elif bottomType == APR_BOTTOM_LONG:
mesh.set_surface_override_material(2,bottomMat)
mesh.set_surface_override_material(3,bottomMat)
However, whenever I try to run the game, I get the following error:
Invalid assignment of property or key 'albedo_texture' with value of type 'CompressedTexture2D' on a base object of type 'Material'.
Wondering how I correctly assign this texture to a material using code.
Thanks!