|Attention||Topic was automatically imported from the old Question2Answer platform.|
Here’s the code.
extends Node2D export var value = 1 var coin_get : bool func _ready(): print(get_owner()) print(get_owner().coins_collected) get_node("Area2D").connect("body_entered", self, "_collect_coin") func _collect_coin(body): print(body) $CoinSound.play() if str(body) == "Player:[KinematicBody2D:1294]": get_owner().coins_collected += value print(get_owner().coins_collected) queue_free()
All of the code under the _collect_coin function runs except for the coin sound. I’ve looked online and am pretty sure that that’s how you would play sound. If you need anything else I’m happy to give it. Thanks.
Do you get an error message or does it just not play? Have you checked that the node is definately called CoinSound and not Coin_Sound or something similar?
Gluon | 2022-01-20 21:35
Hi. Your question doesn’t clearly state what the $CoinSound is and what are the properties it has. I assume it is an audio stream player. Are you sure you have the correct sound assigned to it as a stream?
StopNot | 2022-01-21 13:10
Sorry for responding so late. No error message it just wont play. And yes the node is definitely called CoinSound
Joe_Stinky | 2022-01-26 20:40
Yes $CoinSound is an audio stream player and I have it set to play in the Master Bus. I am also sure that it is the correct sound since I’m able to play it in the editor.
Joe_Stinky | 2022-01-26 20:43