As outlined in Lament’s GDD, there will be two enemies that appear throughout all of the realms. One of which are the ‘Whispers’
What are they?
The whispers are a ranged enemy within Lament, they are described a ‘fast’ and ‘erratic’ enemy – which are key points I want to achieve when designing and coding their behaviour. They also must pause briefly before firing their projectile. I analysed their explanation in the GDD in this Research Post:

Initial Development
I started with creating a ‘9-sliced’ gameobjec, called it ‘Enemy_Whisper’ and turned it red (I would implement its sprite and visuals later, for now my focus was on its behaviour and programming). To start, I gave this gameobject a Box Collider 2D – this was so that it would be able to interact with other gameobjects. I also gave it a Rigidbody 2D, so that it wouldn’t be able to phase through certain gameobjects (like the walls and doors etc.).
But before I started coding a script for the Whisper, I wanted to decide on its behaviour before hand. Given the ‘fast’ and ‘erratic’ adjectives from the Lament GDD, I wanted the enemy to be somewhat annoying. Therefore, as a ranged enemy, I wanted the Whispers to be able to run away from the player, constantly trying to keep its distance – but still be in range to shoot a projectile towards the player, while being out of the player’s range. After some research and looking for resources that could help me write this code, I found this YouTube tutorial about writing a top-down 2D ranged enemy.
Coding its behaviour
With this in mind, I created a script called Enemy_Whisper and began writing its code. Firstly, I created floats that would be used within the Whisper’s movement method:
- speed
- stoppingDistance
- nearDistance
- startTimeBetweenShots
- timeBetweenShots
I then created references for the ‘Player’ gameobject’s position and the Whisper’s projectile prefab. Then, I created a HandleMovement( ) method that would constantly be called in the Update( ) method – this method would do a number of things:
- Cause the Whisper to run away, if its distance from the player was < nearDistance
- Cause the Whisper to move towards the player, if its distance from the player was > stoppingDistance
- Make the Whisper stay still if, distance from the player was < stoppingDistance but > nearDistance
The ‘Enemy_Whisper’ script:

Making it shoot
For now, as this is an early prototype, I will make it so that the Whisper enemy constantly shoots at the Player no matter whether it is running away, running towards or completely stationary. To make the Whisper shoot at the enemy, I need constant access to the players position, so in the Start( ) method, I use the FindGameObjectWithTag( ) method to find the gameobject with the ‘Player’ tag and then set its position (.transform) to a private Transform called ‘player’.
Now that I had access to the players position, I wrote a method called HandleProjectile( ) that would instantiate a projectile. This projectile would spawn whenever ‘timeBetweenShots’ integer was <= 0, this int would go back to its original amount ‘startTimeBetweenShots’ every time the projectiles was instantiated. Essentially this ‘startTimeBetweenShots’ int was the projectile cooldown.

Now that the Whisper was able to instantiate the projectile, I needed the projectile to move towards the player so I created another script called ‘Enemy_WhisperProjectile’. I needed access to the player’s position yet again, I did this by repeating the same steps as I did for the ‘Enemy_Whisper’ script (by using the FindGameObjectWithTag( ) method).
However, if I made the projectile constantly move towards the player’s position, the projectile would be impossible to dodge and would act like a heat-seeking missile. So, I created a Vector2 called ‘target’ which would essentially be the position of the player at the moment the projectile was instantiated. Therefore, the projectile would constantly move to that position while the player is free to move around heat-seeking-missile-free; and once the projectile reached the target it would be destroyed.
The ‘Enemy_WhisperProjectile’ script:

This is what the prototype of the Whisper looked like:
