The issue I have is that ALL ennemies on screen are synchronized even if they appear at different times. Any idea how can I make a small rotation or time offset to the tween when spawning multiple ennemies ?
So far I used a randf_range function inside tween to change speed and it works. But I’m still looking fowrward to understand how to spawn tweens not all synchronized since spawns happens not all at the same time.
If you’re preloading the enemy script, it might start the _ready() function before you even put it into the scene. You can easily check it with a print() statement.
You might want to consider having a separate function something like start_rotation() inside of which you create the Tween instead of the _ready() function, and you call that function only after your spawn the enemy into the scene.
Where does the _on_pattern_timeout callback come from? I assume this is from a Timer Node? What’s the setting on that Timer Node?
If it’s a multiple of 0.5 (which is a duration of your Tween in the original code), then you have accidentally synchronised your spawning to the Tween rotation, so it will always look like they’re synchronised. You’d need to either set it off phase, or randomize the timer.
Indeed ! timer was either a 1s or 10s !
Then I changed it to 1.1s and it now changes a bit the rotation when ennemies are spawn continuously, nevertheless when I pop-up 75 ennemies at the same time for a wave, they all appear synchronized still.
With your timer tweak and my rand_f function in the tween I now have something I wanted !
Thanks !!