To add to Tapio's correct answer: when you instance a node with a script, the scope of that script is that of the node, so for example calling get_position()
will give you the position of that node. The same script can therefore be used for different nodes, and each will return their own position upon calling get_position()
in that script.
As Tapio mentioned, when you need an explicit reference to the node, you can use self
. It gives you a handle to the Node that you can pass to other objects (or, if you like things to be explicit, you can call self.get_position()
, which is the same as get_position()
alone but might be clearer to you).
You will typically need to use self
when connecting signals from script via connect()
.