Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Adding monster behaviors

I’ve been coding some monster behaviors to add some complexity to the encounters. First thing I added was the slime monsters shooting damaging slime at you while in range, which looks like this:


I might increase the range later if they seem too easy to bypass. The slime shots only damage you a tiny bit, but there might be a lot of them coming at you from various sides depending on the situation, so I think that’s for the best. Also the same shots keep healing the monster shooting at you and any other monsters it manages to hit( you can see tiny text “+1” rising from the monsters). I purposefully didn’t limit that either, so monsters can just keep rising each others max HP while you’re close. Also the slime projectiles can be destroyed by shooting at them or by using Laser Explosion( I added light effects to that, I think it looks way better now).

I always try to set these things up in a way that it’s easy to alter later on if I want to, ideally by simply ticking some boxes when possible to change the monster behavior. This is how those options look in engine now, I only need to choose a few things and variables for a script I wrote. I made sure the circle marking the monster territory gets resized automatically depending on the monster tier and also it automatically increases the projectile count based on same tier.


For targeting the slime projectiles I slightly altered the same code I use for Cave Drone facing the mouse( which is just a couple lines I found in every single coding tutorial ever, and it involves trigonometry so I’m glad I didn’t need to figure that out from zero). The trickiest part was making sure every extra projectile was automatically rotated a few degrees so they all don’t shoot in the exactly same direction. I ended up kinda brute forcing that, but hey, it works.

It might be hard to see at this size, but the slime projectiles keep changing between three sprites while moving. I wrote a very simple Gif Maker script a while ago and I use that all over the place in the game. It just cycles through an array of sprites using a co-routine. It’s very convenient being able to just throw on that little script onto any object, adding a few sprites, choosing the speed between sprites and it just works 95% of the time. I also coded in an option to switch between the given sprites randomly or in sequence.

Another seemingly simple piece of code I added is spawning some prefabs either on monster hit, or on monster death. I think it will have many uses, below you can see a monster spawning rocks on hit and a larger amount of them on death( I want to later have Elemental Rock monsters essentially bleeding rocks, but I used any monster I made earlier for testing). The rocks don’t damage you and they can be shot to pieces, or pushed aside using Laser Explosion, but they might block passages when you are trying to quickly escape or such. Also I think it’s just satisfying shooting them apart and little pieces flying all about the place.


I used the exact same code to make higher tier eye monsters spawn low tier bouncing eye monsters I already had made. Anyways, I will keep adding new behaviors and I’m planning a couple fancier ones as well.