I’ve tried many codes to do a coin pickup but everytime i touch the coins colision box it just doesnt work
extends Area2D
func _on_body_entered(body: Node2D) -> void:
if body.name== "Player":
self.queue_free()
this is the last code i tried
I’ve tried many codes to do a coin pickup but everytime i touch the coins colision box it just doesnt work
extends Area2D
func _on_body_entered(body: Node2D) -> void:
if body.name== "Player":
self.queue_free()
this is the last code i tried
Using the groups fixed the problem thx for your help
Im also struggling with this can you provide the fix please.
Put the player in some group, e.g. “Player”
Script:
extends Area2D
const player_group: String = "Player" # replace with group name
func _on_body_entered(body: Node2D) -> void:
if body.is_in_group(player_group):
queue_free()
Connect the signal “body_entered” to _on_body_entered