0 votes

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

https://drive.google.com/open?id=1g4RzAWH-WXR-WOkDoQvebmjGSOpFyTWw

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 :)

Many thanks!

asked Dec 6, 2019 in Engine by JestersGhost (41 points)

2 Answers

0 votes
Best answer

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.

answered Dec 8, 2019 by JestersGhost (41 points)
0 votes

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

answered Dec 9, 2019 by ItsYoBoi (50 points)

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.