![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | enceladus |
Hello,
I’m trying to test out custom signals with parameters in an event bus autoload in Godot 3.5. I have a camera with mouselook with a raycast child node, and I’m trying to print the name of the body the raycast collides with when I click. I have the following code in a script attached to the Events singleton:
signal player_interact(object_under_cursor)
and in my script attached to the world node:
onready var raycast = $Camera/RayCast
<mouselook code>
func _process(_delta):
if Input.is_action_just_pressed("ui_select"):
Events.emit_signal("player_interact", raycast.get_collider())
and finally, in a script attached to a static body in the scene:
func _ready():
Events.connect("player_interact", self, "_on_player_interact")
func _on_player_interact():
print(Events.player_interact().object_under_cursor)
But despite the fact that I have the player_interact signal set up to take an argument, I get the following error whenever I click: “emit_signal: Error calling method from signal ‘player_interact’: ‘StaticBody(StaticBody.gd)::_on_player_interact’: Method expected 0 arguments, but called with 1…”
I suspect I’m also doing something wrong in my _on_player_interact function as well, so any other corrections would be greatly appreciated!