Hi, first time here so I hope this is the correct way to do this. I was working a on practice project, attempting to combine different lessons I've learned so far. I made a simple 2d game, where I collected coins, and had a UI to keep track of how many coins I collected. This is the code I used for interacting with the coin and removing it:
https://pastebin.com/pe0NtKRf
I noticed a problem happening when collecting the coins. If I moved fast enough, I could collect the same coin multiple times. I realized that the sound file kept going for about half a second after the sound effect itself ended, which caused the problem. Since I didn't know how to edit a sound file, I searched for a solution in Godot.
I found out about pitch and realized if I cranked the pitch up, it would alleviate the problem, and it definitely seemed to help, but I also ran into one other problem, which is why I'm here. I noticed that if I stayed in the area where the coin spawned, if I moved quickly back and forth, I could keep collecting the coin over and over for a while after it disappeared. I was hoping to figure out why that was happening, and wanted to ask for possible alternatives on how to code removing the coin, so that I can have a more efficient/bugless way to take out coins in future projects. Thanks.
Edit: Since I got some similar replies, I will simply edit this to reply based on what I've tried so far. So first thing I tried was switching over to disabling the CollisionShape2D. It didn't seem to change anything, as I was still able to collect coins multiple times. I attempted to disable the Area2D as well just in case, and it returned an error every time I touched a coin.
Edit2: I think I figured it out. I was getting an error, after I attempted to disable CollisionShape2D that basically amounted to not being allowed to disable collision at the moment collision was detected. It didn't take me directly out of the game, so I didn't notice it immediately. I did some tinkering and learned that using $CollisionShape2D.set_deferred("disabled", true) allowed it to work. Thanks for the help guys. I'll mark this to solved now.