Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Method not found when emitting a custom signal, but the game seems to work when played.

+2
−0

In Godot 4.1.1 I moved some scenes and started getting parenting errors. I think I got that fixed, but I'm mentioning it in case it is important.

I have an Area2d called House. house.gd has two custom signals

signal player_entered
signal player_exited

func _on_body_entered(body):
	print("Emitting player_entered")
	player_entered.emit()

func _on_body_exited(body):
	print("Emitting player_exited")
	player_exited.emit()`

The custom signals are connected to a scene called Outside.

In outside.gd I have

func _on_house_player_entered():
	print("Player Entered House!")
	var tween = get_tree().create_tween()
	tween.tween_property($Player/Camera2D,"zoom",Vector2(.5,.5),1)

func _on_house_player_exited():
	print("Player Exited House!")
	var tween = get_tree().create_tween()
	tween.tween_property($Player/Camera2D,"zoom",Vector2(.2,.2),1)`

When I run the outside scene, I can enter the house and the camera zooms. I can exit the house and the camera zoom resets.

So far, so good.

The debugger gives two errors:

E 0:00:35:0663 house.gd:20 @ _on_body_entered(): Error calling from signal 'player_entered' to callable: 'Area2D(house.gd)::_on_player_entered': Method not found. <C++ Source> core/object/object.cpp:1082 @ emit_signalp() house.gd:20 @ _on_body_entered()

and

E 0:00:36:0414 house.gd:26 @ _on_body_exited(): Error calling from signal 'player_exited' to callable: 'Area2D(house.gd)::_on_player_exited': Method not found. <C++ Source> core/object/object.cpp:1082 @ emit_signalp() house.gd:26 @ _on_body_exited()

I removed the relevant code from both files, re-attached all four signals and pasted the code back in the files. I still get the errors. What am I doing wrong? (I'm only 7 hours into my first lesson, so there's a lot I don't know.)

History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Alexei, thank you for the cleanup. I have since learned how to do it right. (1 comment)

1 answer

+1
−0

My solution was to carefully disconnect every signal from every node involved, then re-implement and reconnect each signal. Now it works with no error.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Because I don't know what goes on in the background, I don't know what the root cause was. I'd be hap... (1 comment)

Sign up to answer this question »