Devlog #7: Building Animators Through Code


Greetings and salutations,

In today's devlog, I'd like to talk a bit about the animation system. This one is going to be a bit more technical. If you are interested in the technical side of game development, it might prove useful. If you'd just like to know a bit more about how Battle Succubi is being developed, it might be interesting.

As fellow Unity developers will know, Unity has a built-in animation system called Mechanim. This system uses finite state machines to drive animations. Basically, a state machine is a way of modeling some process. At any time, the machine is in some state, say, idle. When it is in the "idle" state, the animation linked to it will be playing. Depending on whether the animation loops or not, the animation might repeat endlessly, or it might play once. The state machine will also have transitions between the states, with different conditions linked to each transition. For example, the "idle" state might have a transition to a state called "move," with the condition being that some movement-related input is received from the player. It might also have a transition to a state called "death," with the condition being that the player's health is zero. Based on these conditions and triggers, the machine will move from state to state, playing the animation linked to each state.


For basic characters with limited animation sets, this system works pretty well. For anything above a handful of animations, this can quickly become a nightmare. Below is an image of a Mechanim state machine from a medieval combat animation set I bought a number of years ago. As you can see, there are a huge number of transitions and a large number of different states. Just looking at it makes my brain hurt! A further problem is that it is extremely inflexible. If I decide that I want to add a new attack, I need to create a new state, link it to an animation, create all the transitions and make sure that the conditions for those transitions are created correctly. What if I want to add a second wind system, like in Middle Earth: Shadow of Mordor, where upon death you will sometimes enter a downed state from which you might recover or you might die? Or, if I decide that I want to change how the overall all system works? In both cases, I must rebuild it by hand from scratch. Removing an attack is less troublesome, but can still lead to issues.


Rather than torturing myself repeatedly with handling all that, I decided I'd make an automated state machine builder. The data for this is stored in a scriptable object, which is a kind of data holder in Unity. You can make your own types that inherit from scriptable object, giving them custom data and custom behavior. I created a Pose Scriptable Object, which contains the data below.


Based on the data, I can go through each pose that a succubus has, check if that state exists in the state machine, check if the animations are correct, and if the state doesn't exist, create that state, and its transitions and animations in the state machine through code. I can click one button to update the state machine, which takes all of 3 seconds.

For something like cowgirl or reverse cowgirl, which allow for what I call "triangular variation" (an up-down pumping motion, a forward-backward rocking motion, and a swivel or corkscrew motion), my code produces a blend tree that mixes between the three variations in real-time based on the user's input.

For other poses, I can get a linear blend tree, or I can get a series of states that transition between each other based on some variable. Why would I want that? Well, in the projects by HFT Games, such as Pleasure Party, the characters often switch between animations based on the intensity /speed of the sex, or how close they are to cumming. It seemed like something nice to include, so it's in the game.

Besides these effects, I have separate animation layers for the head, eyes, and mouth, which allow me to trigger facial expressions and head movements without effecting the main sex animation.

Well, I hope this closer look at some of the complexities involved in making a simple game to fap to was entertaining and informative. As usual, there will be an updated version of Battle Succubi posted later.

Get Battle Succubi

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.