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.

Post History

66%
+2 −0
Q&A Method not found when emitting a custom signal, but the game seems to work when played.

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 c...

1 answer  ·  posted 1y ago by TecBrat‭  ·  last activity 1y ago by TecBrat‭

Question godot gdscript
#2: Post edited by user avatar Alexei‭ · 2023-11-19T07:30:00Z (about 1 year ago)
formatted the code
  • 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()
  • <Stack Trace> 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()
  • <Stack Trace> 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.)
  • 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()
  • <Stack Trace> 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()
  • <Stack Trace> 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.)
#1: Initial revision by user avatar TecBrat‭ · 2023-11-19T01:18:39Z (about 1 year ago)
 Method not found when emitting a custom signal, but the game seems to work when played.
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()
  <Stack Trace>  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()
  <Stack Trace>  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.)