![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | skoprimon |
I’m getting this error and I’m not sure why.
For simplicity’s sake, let’s assume I have two scripts: animal.gd and farm.gd.
Animal.gd looks as following:
class_name Animal
var name
class Cow extends Animal:
func _init():
name = "Cow"
class Sheep extends Animal:
func _init():
name = "Sheep"
and Farm.gd looks as following:
const Animal = preload(".../animal.gd")
var animals : Array
func populate_farm():
animals.append(Cow.new())
animals.append(Sheep.new())
I’m getting the following errors: Identifier "Cow" not declared in the current scope.
, Identifier "Sheep" not declared in the current scope.
I’m not sure if I’m doing something wrong, but I have no idea how else to do this. I also can’t find anything online that explains how to do this. Any help?