Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Gamer78 |
I am trying to send a signal on contact with my player and a coin that updates the coin amount. Here is the code for the collision with the player
func _on_Coin_area_entered(area):
if area.is_in_group(“player”):
hide()
emit_signal(“coinget”)
I connected the signal coinget to this function
func _on_Coin_coingetn():
coins += 1
$HUD.update_coins(coins)
It doesn’t update the counter, but I tried similar code with a timer instead
func _on_TestTimer_timeout():
coins += 1
$HUD.update_coins(coins)
and that code worked. Any way how to make it work with the signal?
How are you connecting the signal?
exuin | 2022-12-10 02:50
I instanced the coin scene under my main scene then connected the signal to that main scene’s script
Gamer78 | 2022-12-10 03:11
Did you connect the onConinareaenteered(area) to the area_entered signal?
dethland | 2022-12-10 05:44
If the emit() is not working, I guess the func onCoinareaentered is not called.
dethland | 2022-12-10 05:46
The function is being called though, because the hide() works so I don’t know if the signal isn’t being emitted or what.
Gamer78 | 2022-12-10 16:12
Well, if onConareaentered() is called, emit_signal(“coin_get”) shouldn’t be the problem. Then is probably the signal “coin_get” having a connection issue.
dethland | 2022-12-12 05:36