In order to be able to attach a script to a node, it must at least inherit from Node
. Otherwise I'm not sure if it's supposed to work.
If your script doesn't have any extends
, then it won't be a node.
Such a script can be instanced by doing this though:
var obj = preload("bullet.gd").new()`
Or this:
const Bullet = preload("bullet.gd")
func _ready():
var obj = Bullet.new()
But this won't create a node instance or attach to a node, it will just be a custom object with variables and functions, that only lives in code.
Also, in addition to inheritance, I'm not sure if _init
is called on Node scripts, usually we have _ready
or field initializers.