Hi! Today there will be a devlog about the interaction system, probably one of the simplest and most complex things in game development.
First, what is an interaction system? In simple terms, it will be a system that helps one object interact with another object. And almost all games that exist use interaction systems of various types of complexity.
And if everyone uses interaction systems, then why do I write that this is one of the most complex things in development? Well, it's because the more things you want to add to the game, the larger the interaction system becomes and the harder it is to control.
I will give a simple example from my own game, a simple conversation with an NPC :
For such interaction in the game, you just press one button and the interaction occurs, the main character talks to the NPC. But what actually happens in the game? Let's take a look in order:
Before starting the interaction, a prompt appears (an arrow above the main character), and the character receives data about what he can interact with:
Then the code waits for the player to press the action button, and when it receives it, it checks what kind of interaction needs to be launched:
As you might have noticed, a lot of things happen here, such as turning the character to the object of interaction, changing animations, and the like.
In line 24, we launch the interaction to the object (to the NPC) and the object itself also checks what exactly needs to be launched:
And now that the desired type of interaction has been selected, we finally launch the correct dialogue with the NPC.
This is the most elementary way of interaction, when the object has more than one type of interaction. All the checks that you have seen are needed only to understand whether to have sex with the NPC and what dialogue needs to be launched, and that's it. But this already has several steps and the system does not work well when another type of interaction is added. If you look closely at the second point, you will notice that at the bottom I have additional conditions for fishing and a throne mini-game , and if I wanted to add something else, I would have to add new conditions at the top.
Of course, I understand that my code in the game "Life with the Tribe" is not even close to perfect, this is the reason for my reworking of the game now. But the interaction system is the life of the game, what the player does and the game's reactions to the player's actions are solved by this system. Therefore, I lost a lot of time and was able to develop an interaction system that expands well and there is no such problem as before, but at the same time it has become many times more complicated.
Here is an example of an unfinished port of a character from "Life with the Tribe":
As you can see above, instead of writing code, I made another system that works with nodes (those green icons). What is the difference? Because I broke down all the actions during the interaction into small components that are launched in order from top to bottom.
So I have a node that changes where the main character should look, a node that changes the player's position to the desired one, as well as the conditions when and what dialogue should be launched, etc. It looks easy, but now it requires a greater understanding of the entire interaction action, as well as breaking down each detail into components. Only now in the not completely completed port of the game I have this many scripts, each of which is responsible for a different action:
And this is not the end! There will be many more actions, as it is planned to add a new way of interacting with NPCs where you will choose what exactly you want to do with them:
Of course, this will already be in the DLC, but adding another type of interaction will now not be so difficult and I will be able to expand the many systems that were in the game before. For example, I recently realized that I could make events where NPCs could interact with each other (And now the Futa leader can finally fuck someone!), but that's for a devlog about DLC.
As you can see, the interaction system may seem easy to the player, but even the simplest action requires many steps. And the more complex the interaction, the harder it is to expand the game, and I'm sure that at some point even my interaction system will hit its limit and I'll have to find other ways to implement interactions.