Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | abelgutierrez99 |
Hello, I’m new to Godot
I have an scene (made with Blender) that has two materials. I want to change one of the materials using code. This code illustrates what I want, but doesn’t work (the variable center
is the MeshInstance
with the two materials):
extends Spatial
const centerMaterials : Array = [
preload("res://Assets/MapTiles/empty/Center.material"),
preload("res://Assets/MapTiles/blue/Center.material"),
preload("res://Assets/MapTiles/green/Center.material")
]
onready var center = $Circle
func _ready():
pass
func changeCenter(newCenter):
center.material/0 = centerMaterials[newCenter]