Monokkel
(Monokkel)
April 20, 2018, 3:26am
1946
leo_bar:
hi
first of all I wanted to thank you fro the realy great toolkit that you made (I am using its concept in my project a lot). it’s an amazing work and the support and help you give is impeccable. And I’m sure that the help and learning you give to many people through your system is Very satisfying for you.
My project is a cross between a turnbased and a third person.and i now I just started to add multiplayer and came back to your toolkit and I am a bit confused And hope you can help me.
My problem is this:
In what had been so far - the ai was run throw ai controller and it was clear to me that when the boolen aicontroled is true its go to the ai turn and ai controller …
In the last update I can not figure out where I find the places where the I can find the transition to the ai (singleplayer).
In addition, I understand that now the AI is executed through the same controller
If you (or anyone else from the forum) can explain the way in which the last update workflow of the ai , so that I can convert my old project I will be very glade
thanks in advance
leo
Note: I have already answered this question over e-mail since there were some issues with the forums. Here is an edited version of my reply in case other developers might be wondering the same thing.
First my inital answer as I misunderstood his question:
Hi Leo,
the new update is a big change, so it is not surprising that you are confused. The next tutorial I plan to make will be about the ability system, which is where AI is now handled. Sorry it is taking so long to make new tutorials. Work has been crazy busy. I’ll explain where to start looking, though.
So before when a unit was activated, it checked whether it was AI controlled (looking at the boolean) and had the player or AI controllers take over from there. This was all well and good in games where you want all AI and player units to act the same, but it is a bit awkward to work with if you want units that act very differently.
To change this, AI (as well as interpeting player input) is handled by whatever ability blueprint the units are using. This makes stuff much more modular, as you can change the entire behavior of a unit just by changing the ability it is using.
So now, instead of going to the AI controller when a unit is activated that has bAIControlled set to true, it goes to whatever is set as the DefaultAbility in the public variables of that unit. When that ability is activated it first runs some nodes that work for both AI and player units and then goes on to nodes specific for AI or players. I recommend checking out the base class for abilities (BP_Ability) first and then looking at BP_Ability_MoveAttack), as these two together do the same job as the AI controller did before.
If an AI unit has a AbilitySystem component it is a bit more complicated, as here the AI unit can have multiple abilities and will loop through all of them to determine which one it wants to use in any situation.
Hope that helps you find out where to look. Let me know if I can clear up any other confusions.
Then my second answer where I address his actual question:
In the example levels provided I have just set bAiControlled to true manually. You can set it to true however you want. Creating child blueprints is one way. Setting them on spawn is another (bAIControlled is set to Expose On Spawn, so when using SpawnActor you can set it then). You could loop over all units at the start of the game and set it to true whenever faction = enemy. Or you could edit the construction scripts so that the value of AiControlled is set based on the faction there. It is just a variable so you can set it using whatever method you prefer and that works best for your project.