Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | nightblade9 |
I have a player class with a simple signal:
extends KinematicBody2D
...
signal player_moved(position, facing)
I also have a WarpAtBoundaries
class which tries to connect to this signal:
extends Node
func _ready():
print("Auto-warp reporting")
# Called when the node is added to the scene for the first time.
# Initialization here
self.connect("player_moved", self, "_on_player_moved")
func _on_player_moved(position, facing):
print("Player moved to " + str(position) + " and is facing " + facing)
In the debugger, I see an error that Attempt to connect nonexistent signal "player_moved" to ...
. I see the auto-warp reporting
message, but not the print of the player’s coordinates.
My hierarchy for these two nodes:
Start.tscn
is a node with aPlayer
instanceStart.gd
callsload(...).instance()
to create an instance of a map- That map (eg.
Meadow1.gd
) callsload("WarpAtBoundaries.gd").new()
I don’t understand why the signal isn’t being defined / being connected correctly. I can add print statements and see the event is firing, but I can’t connect/receive it.
I tried calling load("Player.gd")
in the warp class, and adding a singleton “SignalManager” class like this post, thinking that the warp class doesn’t know about the signal; but the error persists.