Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | PeterA |
Hello there. I am getting this error
Invalid call. Nonexistent function ‘instance’ in base ‘Nil’.
when I instance a scene from a dictionary as per the example below:
export(PackedScene) var houses
export(PackedScene) var farms
var buildings = {'House':houses,'Farm':farms}
func next_building(typ):
print(build_offset[typ])#To check if typ is valid
var b = buildings[typ].instance() #ERROR
next_building('Farm')
If instead of instancing from the dictionary I do it like this then there is no problem.
var b = farms.instance()#Works