So I have a Raycast that when it detects the player, it emits a signal called "crossed_line" (for a racing game). I followed the directions of many tutorials to create the following code:
in the Raycast script:
func _on_Area_body_entered(body: Node) -> void:
and in the Player script
func _ready() -> void:
var wall = get_node("/Main/Path2D/follow/WallDetector")
wall.connect("crossed_line", self, "handle_crossed_line")
func handle_crossed_line() -> void:
print ("I crossed the line!")
This is exactly the format I see multiple tutorials have you do, however I get an error in the player script that says "Attempt to call function 'connect' in base "null instance" on a null instance."
When I delete the player script and run the game, the game does print "nice" and "AH" whenever the player crosses the line, so I know that the raycast2d works and that the signal works.
I am also positive that the path to the node is correct.
I am not sure what I could be doing wrong, though I know it's something...any help would be greatly appreciated!