Devlog 3: Enemy AI


Devlog 3: Enemy AI 

A lot has happened since my last devlog! You may have noticed that my environmental sprites have changed - I'll talk about that in a future devlog. In this devlog I'll be going over the enemy AI that has been implemented so far, starting with the basic skeleton.

The Spooky (Friendly) Skeleton

A homing skeleton.

This little fellow has two behaviors: distance-dependent homing, and a lunge. They track down the player by predicting where the player is heading and moving towards that point. When they are close to the player they switch from predicting movement to heading straight for their current location.  The player’s future position is calculated by taking their current position adding their velocity multiplied by the amount of time we want to predict into the future.

I've highlighted the lunge by swapping the skeleton's colour to red while it's occurring.  In my testing feedback it was pointed out that the red flashing makes it look like the skeleton is taking damage. With this in mind, I'll use something like a trail effect instead to denote the speed boost. The skeleton isn't attacking for the full duration of the lunge - there is a separate attack script that is triggered when the player is within range. In a future version, this will be animated.

In order to beat the skeleton we only need to hug it. Skeletons die immediately upon contact with the hug collider, and are mostly only a threat due to their constantly growing numbers. When skeleton’s get hugged, their souls can finally be put to rest.

Visions of the future - attack effects

At the moment there’s no feedback showing that player has taken any damage, unless you're looking at their health value. One method would be to make the player get knocked backwards when they take damage. Another would be to add a sound effect to the attack so that it stands out. Both of these will help sell the physicality of the enemy attacks, and also let the player learn more easily when they have failed to dodge an attack.

Don't Be Rude To Grandma


The grandma skeleton’s interaction works the way that was laid out in the original concept log: if the player is within a certain range, the grandma will begin telling them a very long story. The player must stay facing the grandma for the duration of the story, otherwise they’ll take constant damage as long as they are within the radius. The grandma also slowly moves towards the player, but is trivially evaded due to her slow speed.

The strategy for the player is to keep facing the grandma by holding down shift (which lets you move freely without changing the way your character is facing), and avoid or hug the attacking skeletons until the grandma has finished talking. At that point she can be successfully hugged 😊. The grandma’s ‘story zone’ is a simple circle collider. The talking script checks every frame to see if the player is inside the collider, and acts accordingly if the player is doing something rude and deserving of recurring damage.

The slowly printing text box is achieved using a coroutine. Every line of dialogue is stored in an array. A coroutine then takes the next letter from the current line, prints it, then waits for a brief moment because re-running the coroutine. The effect is that dialogue appears on screen one letter at a time. Neat!

Visions of the future - completed logic

This implementation is still a work in progress – the detection for the player facing the grandma isn’t perfect, and the player does not always take damage when they should. I also need to tweak the radius in a way that is both fair and interesting from a gameplay perspective. If the radius is very small, it is easy to see if we are in the radius of the grandma because she is guaranteed to be onscreen. The downside to this is that the grandma becomes too easy to avoid. If her radius is very high, we can be ‘in conversation’ with her before we even see her, which could cause the player to take damage without being able to realistically avoid it.  On the flip side, I like needing to keep the position of the grandma in your mind even if she is offscreen. This rewards players who are careful with their movement, and reinforces the gameplay element of needing to juggle two things at once.

That's all...for now

And that's it for enemy AI so far. What do you think? The next log will be focused on upgrading our visuals - I hope you enjoy it :)

Files

Build-oct-5.zip 15 MB
Oct 05, 2022
NewBuild.zip 7 MB
Oct 05, 2022

Get Zombie Hugger

Leave a comment

Log in with itch.io to leave a comment.