This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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 onCoinareaentered(area):
if area.isingroup("player"):
hide()
emit_signal("coinget")
I connected the signal coinget to this function

func onCoincoingetn():
coins += 1
$HUD.update
coins(coins)
It doesn't update the counter, but I tried similar code with a timer instead

func onTestTimertimeout():
coins += 1
$HUD.update
coins(coins)

and that code worked. Any way how to make it work with the signal?

Godot version 3.5.1
in Engine by (17 points)

How are you connecting the signal?

I instanced the coin scene under my main scene then connected the signal to that main scene's script

Did you connect the onConinareaenteered(area) to the area_entered signal?

If the emit() is not working, I guess the func onCoinareaentered is not called.

The function is being called though, because the hide() works so I don’t know if the signal isn’t being emitted or what.

Well, if onConareaentered() is called, emitsignal("coinget") shouldn't be the problem. Then is probably the signal "coin_get" having a connection issue.

1 Answer

–1 vote
func onCoincoinget():
     coins += 1
     $HUD.updatecoins(coins)

you got an extra letter "n" added there, i think it's disconnecting your signal

by (23 points)

I made a typo when typing the code I think, there isn't and n there in the actual code
here is what I'm currently using

func onCoincoinget():
coins += 1
$HUD.update
coins(coins)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.