Ah, I see an issue. In your Coin.gd, you left queue_free()
outside of the if loop.
extends Area2D
signal e_grabbed
func _on_coin_body_entered(body):
if body.name == "player":
emit_signal("e_grabbed")
queue_free()
That's all I would do. If the system fusses, try putting the Player scene into a Group called "player", and change if body.name == "player"
to if body.is_in_group("player")
.
In mainscene.gd, I'd put randomize()
into the _ready()
function, and have var coin_scene = preload("res://scenes/coin.tscn")
between the topmost function, and the extends
line.
Apologies if this is a bit of a mess.