Error after connecting signals in editor

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JestersGhost

So I’ve just started playing with Godot (loving it so far, btw), and am trying to use signals:

In this project (expanded from the isometric sample project) I have a Node on the player scene, “Controllable”, which detects keypresses and emits the relevant signals (in the picture, it was “move_right”). I then have a separate node on the player scene, “Moveable”, which reacts to that signal to generate the relevant movement.

I connected the two via the editor Node panel (as you can see on the far right in the image) - I created the methods on connection, then added the relevant code, so I’m pretty sure the signature of the methods is correct. However, as you can see, the methods aren’t found. The error says it’s trying to find the method on “Node”, which obviously isn’t going to work, but I have no idea why when the connection is with “Moveable”. Right-clicking on the connection and choosing “Got To Method” takes me to the correct place, so I’m at a loss as to why this isn’t working.

I’m guessing I’ve maybe some kind of noob error, but I have no idea what :slight_smile:

Many thanks!

:bust_in_silhouette: Reply From: JestersGhost

For reference, this turned out to be an issue in the class receiving the signals - I was re-using a variable name already used higher-up the hierarchy, and these seems to have been confusing the signal routing. Removing references to that variable made everything start working as expected.

:bust_in_silhouette: Reply From: ItsYoBoi

Did you use signals to get your character to move. I have never seen that done before.

It gives good code re-use and separation - having the Node that handles the physics of movement be apart from the Node that generates movement commands means I can simply swap in an AI Node that generates the same movement commands instead of the keyboard handler without having to change anything else.

Likewise I can swap the movement Node for others (one that handles flying movement, for example) without again changing in actual code. Add a different child Node, re-link the signals and away you go.

JestersGhost | 2019-12-09 11:11