I managed to make a sort of fix by cycling through the different spawn points so that each new enemy can only spawn at one spawn point, then it changes the point for the next enemy.
I suspect that this hasnt been done right as if they are all on the same collision layer, and you have set them not to interact with themselves then they shouldnt be.
More screenshots of collision setup and signals needed.
I should think that one would want collisions to be detected and treated, otherwise they will âwalk throughâ each other like ghosts. Scattering the spawn point coordinates worked for me, and the spawned creatures turn away when the come into contact with another.
Depends on the game and gameplay. For example you wouldnt want to do that in say Asteroids.
It definitely sounds like enemies colliding due to spawning inside each other. And @OriginalBadBoy is right, you probably didnât disable collisions correctly (or maybe something in your code is re-activating them).
To avoid disabling collisions, you could just check if a position is empty before spawning an enemy:
- Select a spawn position (Vector2), donât spawn an enemy there yet.
- Spawn an Area2D (with the same size and shape as your enemies) at that position. Configure its collision layer/mask so it can detect enemies, but enemies canât detect it.
- If the Area2D doesnât collide with any enemies, then the position is empty, so spawn an enemy there.
- If the Area2D collides with an enemy, then the space is occupied and your code should pick another position at random near the spawner, test this new position with an Area2D again, and repeat this until it finds an empty spot.
- Repeat the steps above for each enemy, until they have all spawned.
This isnât necessarily the most optimal solution, but it can work. Some people might suggest using raycasts instead, but the Area2D method might be easier as a start.