I have script called Mob and a script called goblin.
My mob is defined as class_name Mob and has a few functions that goblin will inherit.
all the mobs I make will have a kinematicbody2d, sprite, and collidershape2d.
when a mob is clicked I want to send a signal: ideally using the input_event(viewport, event, shape) signal defined in kinematicbody2d
my Mob class is being treated as an abstract class essentially. Instead of rewritting and configuring the signal in each mob, I want to write it once in my Mob class, and have all mobs run Mob.init() when they load in to register and connect the signal.
the problem is: my mob is not in a scene, and therefore I cannot simply click on the signal and register it in the class
instead I have tried to code it:
var b = getnode(".") //this gets the kinematicbody2d which is the root of all my mob scenes
b.connect("inputevent",self,"onclick",[viewport,event,shapetx])//this should ideally connect the event to a function in my mob class
unfortunately, I get an error: Identifier not found: viewport
so what i can tell is each of my arguments for the signal are not defined, and I have to define them before i connect the signal, but I don't know how I'm supposed to get these values to make this work.
Is there a reliable way to do this, or am I approaching the problem wrong?