How to duplicate an Area2D and have it still play the animation?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By soybean

I made a coin and breaking platform and the animation plays when the player touches it, but the duplicates of the coins and platforms don’t play the animation, and just dissappear when the player touches it. I tried making seperate scripts for each thing too but it didn’t change anything.

this is the script im using:

func _physics_process(_delta):
	var bodies = get_overlapping_bodies()
	for body in bodies:
		if body.name == "Player":
			$AnimationPlayer.play("destroyed")
			yield($AnimationPlayer, "animation_finished")
			queue_free()
		else:
			$AnimationPlayer.play("idle")

I’m really new to Godot so this might be a noob question :frowning:

Edited the OP to fix code formatting…

jgodfrey | 2022-12-28 18:11

but the duplicates of the coins and platforms don’t play the animation

How did you duplicate the coins?

jgodfrey | 2022-12-28 18:14

In the scene tab I just control d the node

soybean | 2022-12-28 21:11