Hi fellow godots
I have an enemy character that shoots projectiles whenever its animations lands on a certain frame. I also want to duplicate this enemy all over the level.
Simply put, I want to randomize when this enemy starts its animation frame, to offset when its projectiles are fired. At the moment, ALL enemies fire their projectiles at the same time, eek.
This is what I've tried so far...
1) Exporting an integer variable on the enemy, to be used to manually set the animation frame of each duplicated enemy.
extends CharacterBody2D
@export var anim_start_frame :int
func _ready():
$AnimatedSprite2D.frame = anim_start_frame
2) No export variable, only using the randi() function.
extends CharacterBody2D
func _ready():
$AnimatedSprite2D.frame = randi() % $AnimatedSprite2D.frames.get_frame_count("Idle")
Neither of these approaches did the trick, the latter throwing an error...
Invalid get index 'frames' (on base: AnimatedSprite2D ()')
I'm also using an AnimationPlayer with this enemy and have a script on there signalling when it changes animation frames, wondering if I can use that for this?