Hello everybody, it’s been a while!
I finally managed to get back to work after these long holidays… And since the beginning of October, I’ve worked mainly on the combat system, and interactions/items/weapons. So the incoming demo will focus on this part. I won’t post again the tutorials and 1st level, even if I fixed a few bugs on them. And today post mainly describes the creation of enemies.
I – Moving Pirates!
OK, let’s start by talking about pirates! Of course, it doesn’t make any sense to code weapons/interactions if there are no other characters to interact with. So I finally used my old pirate character (see this post) to bring him to life. I added a few animations, especially punching, aiming, being stunned and seizing a weapon. By the way, I used a quite singular weapon I had the idea of a while ago: an anchor. It can be used either as a melee weapon (it goes well with the tough bad-guy look of the character as well as the overall sea theme) or as a range weapon (it looks so much like a giant crossbow!).
This is a big anchor ๐ And yes, I made a test level where you can walk on water. Just for fun.
Once every models and animations are created, the most difficult part comes in: synchronizing everything in the game. Because depending on the state of the pirate, the weapon can be held on his back, or in his hand. As the character is deformed by a skeleton, this means that the weapon is linked to a particular bone to follow the movement of either the hand or the back of the pirate. But when the character reaches for the weapon, this link changes. And it has to change at a very precise time and place. This is very long to set up and finely tune, because it involves a lot of going back and forth between the 3D modelisation software (Blender for me) and the game engine (Unity), as well as executing the game frame-by-frame.
The precise moment when the weapon goes from the back to the hand of the pirate. This seems so simple when you look at it… But I spent hours on this.
So I finally set up something I hope is quite generic and flexible: the pirate can carry various weapons and can have different moves to automatically catch the right one. With this sytem, I should be able to create enemy variations quite easily: various weapons, ammo, strengths, speeds, aggressiveness, textures and skins… And of course, the pirate should be able to choose his weapon according to some kind of analysis of the surroundings….
I also added a few particle effects and sounds on the hits.
II – Reacting Pirates
…Which leads us to the high-level AI (artificial intelligence): now that basic moves are set up and well coordinated, I want my pirates to have some kind of “intelligence”, or, at least, believable behaviour. And this is generally a huge burden in video games, even the most recent ones. I already tested a few simple algorithms myself in my little game World of Ninjas as to how enemies can react to the player behaviour.
I kept the same global scheme, and, for the moment, in World of Thieves, enemies basically shoot at the player when they see him, try to get close to him and punch him when they don’t have any arrows left, and search for him when they can’t see him anymore. Of course, it is impossible to create a perfectly realistic behaviour, because there are so many things to take into account. So, as usual, I asked myself a lot of questions, like:
- Do they have an infinite number of arrows? If yes, they don’t ever have to come close to the player, but that’s obviously unrealistic.
- Do they punch with their bare hands or with the anchor? Can they switch? If yes, when would be the moment?
- When they “die” (fall asleep actually), what happens if they’re holding their weapon? Do they keep it in the hand? Do they put it back on their back (which is in no way likely to happen when you fall asleep)? Do they leave it away on the floor? If it goes away, the player will surely try to catch it and will be disappointed if he can’t.
- If a pirate has many weapons, how does he choose the one to use?
I’m lucky they don’t have infinite ammo.
Usually all these questions lead me to think about “what would *I* do?” Then, “Is it interesting for the gameplay?”, then “How many additional modeling, texturing, animation, coding, and sounds this ‘simple’ move will require”? Is it even possible to code such a behaviour for a real-time game? Does the fun it gives counterweights the required time and problem solving to set this up, which you can’t obviously know without actually doing it?
And one always has to sacrifice some aspects to save others. It’s ALWAYS a matter of compromise. But at the end, the only question I should have to ask myself is “is it believable enough to have fun?”. And I regularly see people playing my game without even noticing all the little behaviour/logical flaws I see everywhere.
III – Cycling the behaviour
So I’ve got something quite OK for the fight attitude. But I want my game to be a “non-killing” game. So enemies won’t disappear when you beat them. They fall asleep where they are. But this raises other problems:
- Do they fall asleep forever?
- If no, when do they wake up?
To this point, I thought it could be done easily: they sleep for a while, then wake up with their full strength and they’re back in the game, remembering nothing because they are stupid pirates.
But while coding attacks from the player (more on this in the next post), I noticed that it would be funnier if there was some kind of impact projecting the enemy back (as in a lot of video games by the way, that’s no coincidence). But, by adding those impacts, enemies may be thrown away in areas where they are not supposed to walk (sloppy roof, water, another enemy, a big hole from which they can’t get out…). This simple decision made me think a lot about what an enemy who falls in such an area should do? Just disappear? Dig and get back to his previous place? Be killed? Teleport back?
The hero can do a lot of moves, but the enemy doesn’t have the climb ability (for purely technical Unity reasons), so I had to find something else…When I was sick of spending so much time on such an insignificant choice, I finally gave up and chose to make the ennemy stay there, and “reset” to his start place when the player is far away and doesn’t look. While waiting, I will make him have a funny animation like playing dices, playing with his parrot, drinking rhum or whatever a pirate does when he waits. About the water, if they fall in the sea, they just stay there too, enjoying the calm while floating on their back. I like the idea of “water-addicted” pirates who become useless once surrounded by water. Of course, I’ll have to make this funny by making them say stupid things like “Oh I forgot how cool it was to take a bath”, “Waaaaaaateeeeeeer”, and other “Ooooh the sky is so beautiful from here”, in short, things a really-tough-pirate guy would certainly not do. But, hey, this is a humorous game, and those guys already have a “Mom” tattoo.
Bath for everyone! And yes, in this level, you can’t walk on water. I had to test the swim and floating moves ๐
That’s incredible to see how a simple decision as “arrows project back enemies” impacts other aspects like “can the psychology of the pirate justify its non-action in water?”. Everything is so intricated if you want to create something consistent (not necessarily realistic, but consistent in its own way)!
So at the moment, pirates react… But they are still quite stupid (it’s Artificial Stupidity), you can check it in the next demo ๐
In the next post I’ll talk about creating the equipment/weapons for the main character.