Monster Spawning Algorithm

Godot Version

4.2 Mono


I’m making a BulletHell game like 20 minutes till dawn. I have a bat - monster (everything is there, intelligence and stuff, just need to add to the scene), and there is a player. (Hierarchy in the picture). I want to create new enemies in the Enemys node, and I’ve thrown a small billet:

using Godot;

public partial class EnemysNode : Node2D
	[Export] private int SpawnDelay {get; set;} = 10;
	[Export] private int SpawnCount {get; set;} = 3;

	private CharacterBody2D player {get; set;}

	private Timer timer {get; set;}

    public override void _Ready()
		player = GetParent().GetNodeOrNull("Player") as CharacterBody2D;

        timer.WaitTime = SpawnDelay;
		timer.Autostart = true;
		timer.OneShot = true;

		timer.Timeout += OnTimerTimeout;

	private void OnTimerTimeout()


In the OnTimerTimeout function you need to write an algorithm for spavin by a mob. Criteria: Behind the character’s screen and not far beyond its borders.