Animating multiple 3dsprites at once

4.2.2

Newbie who basically can’t code here.
I want to create a 3d environment with 2d sprites as the objects on the environment itself. I have successfully done this process individually to my liking, however, I ran into a hurdle when trying to populate the area.
I want to add multiple of the same sprite, with the same animation for some grass sprinkled throughout the level.
I am using the AnimatedSprite3d, however when I test it, only the first instance of the sprite is animated.
I followed a tutorial, and it used this code to enable the animation on the scene:

@onready var anim = $grass
func _ready():
anim.play(“grass”)

Imgur

But for this to work with what I have in mind, I would need to have one instance of this code for each individual grass sprite.
I organized my grass sprites into a single branch, and don’t know if I could call that instead for the variable, as in, use one callout for every sprite node under that branch in the $.

If there is an easier or more elegant solution I would welcome it too. I have looked into using shaders to make the animation in a flipbook style, but do not know if that would be better.
Below is an image of the layout of the scene if it is of any help to see what I’m going for

Whenever you find yourself copy-pasting multiple nodes with the exact same behavior, think if they could be instantiated instead. In this case the most straightforward solution is attaching the script to a single “grass” instead (making it govern its own animation) and instantiating several copies of it. I’m not sure this is optimal (identical blades of grass do indeed seem like a job for a shader or perhaps a single AnimationPlayer), but it beats going through the entire list of them with code.

You can use the auto play for this, the animation will start on it’s own. or put a script directly on the grass rather than access with $

2024-06-10-103756_293x129_scrot

Here’s what a script directly on grass would look like.

extends AnimatedSprite3D

func _ready() -> void:
    play("grass")