How to Invoke a Function from Another Node Script?
I'm Trying to Invoke a Function from One Node into Another Node1_Script: Extends Position2D Func Sample(): Print('Well You Invoked Me, Now What?')...
I'm trying to invoke a function from one node into another
Node1_script:
extends Position2D
func sample():
print('well you invoked me, now what?')
Node2_script:
tool
...
func some_function():
print($"Node1".sample());
but it gives the error:
Invalid call. Nonexistent function 'sample'
1 Answer
Ah I got the problem, it was in tool mode
for future reference, if you want to invoke a function in tool mode you have to make sure the function definition is also in tool mode:
Node1_script:
extends Position2D
tool
func sample():
print('well you invoked me, now what?')
Node2_script:
tool
...
func some_function():
print($"Node1".sample());