Very neat! Yes, the music did get blasted, of course:D
Having had some experience with this kind of game myself using object pooling should fix the issue you’re facing with the swarmlings.
Simply have an array of swarmling nodes:
# Pop elements from this array
var swarmling_buffer: Array[Swarmling] = []
# Into this array when you need a new swarmling, then set properties
var swarmling_instances: Array[Swarmling] = []
var swarmling_scene = preload("res://path_to_swarmling_scene.tscn")
func _ready():
for i in range(1000):
var swarmling = swarmling_scene.instantiate()
# Or Swarmling.new() if using script-based instances
add_child(swarmling)
swarmling.hide()
swarmling.set_physics_process(false) # Pausing physics
swarmling_buffer.append(swarmling)
This approach makes it so the swarmlings don’t have to enter and exit the game tree a lot, which causes lag. It’s better just to pause processing and hide them when not in use. Then when you need a new one you unpause, set properties to be correct (position, internal parameters etc.) and unhide it.
Cheers!
PS: The background is probably also nodes, which probably cause more lag than the swarmlings? I’d make sure to disable as many unnecessary features on those as possible to reduce lag. Perhaps even using a dedicated shadermaterial to draw the sprite could be good. For instance you could relatively simply stack the texture on top of itself and squish it into a trapezoid shape. (might be easier than lining up polar transformations, though you could find code online for that!)