Enemy animation script


Faffing 

Not much visually to update you with as life has been predominantly about mucking around with the code and tweaking and altering bits on how the enemy behavior works.  But here are a few features I've added. 

Blocking system

the player can now block enemy attacks, eventually i want to add a block strength system, so eventually your guard will break if you block too much, or try to block an enemy with a much more powerful attack. for now though, you can block EVERYTHING. Another simple tweak I can do for this is have the block on a timer, so you have to time your blocks carefully or you will still get hit. But we'll start here with humble beginnings and build off of it. 
A lot of this early code is to help me define what kinds of animations I will need to work on for the character too. 


Enemy animation system

The enemies all run via a main parent enemy object.  Each child enemy object has its own attributes. Things like, move speed, attack speed, how hard they hit, etc, is all determined by the individual child object.
They can attack in 4 directions and I've been setting up a script to handle all the sprite changes where they are needed.  It looks at what direction the enemy is moving and applies its correct walking sprite, if they stop moving it applies the idle sprite and when in attack mode it looks at which way they are facing and sets the sprite accordingly. Pretty pleased with it, it will need some refinement when the correct animations are in place, but we have a sturdy foundation. 


I wanted the enemies to have a "tell" for when they are about to attack, this will be part of the attack animation, and the code has accounted for that by adding in an attack delay, that can be customised to each individual monster to allow for different attack speeds. some enemies may take a bigger swing, take longer to charge a spell, pull a bow string and so on. 

When the enemy is allowed to attack, this starts the animation right away, but they wont LAUNCH the actual hitbox that causes damage until after the attack delay. I hope that makes sense. sometimes i find explaining these concepts to be harder than coding them. 

The goal of all of this is future proofing the production, so that I can add a lot of different enemies very easily without having to create heaps of unique code for them. 

I'll have more news soon, and recently have some very exciting news about the games soundtrack. watch this space. 

see you in the next one. 

Bren

Comments

Log in with itch.io to leave a comment.

(+1)

I like the idea of giving a tell, which really allows the player to feel like there's a "reward" (in this case, blocking) for playing and paying attention to the enemy.

(+1)

yeah, I always appreciate a good tell.  Let's the player learn about each individual enemies attack pattern. its a low cost to add feature too to add a nice variety to all the enemies.