How to create own an AIController for each bots?

Hello,

I have created several blueprints character then set him my BotAIController (where created random actions and movements that can not be the same, I do not use blackboard and behaviorTree, I have no common data)

But they start at the same time to perform the same actions.

I want allow for each character existed a separate instance of the controller. How can I do it ?

Thanks!

Hello Syntopia,

So as I understand you don’t unreal stuff for AI Behavior tree etc… ? ok.

Anyway, what you could do is create as many AIBotCrontroller you need for your character and make them possess a character.

To be honest, I don’t see any problems in particular.

If you can give more details, I can find an answer that fit better.

gamer08

I will describe two scenarios. In the first test, pure blueprint, I created a MyChar1_BP derive from standard character class.
Then I create a MyController_BP derive from standard AIController, and fill it with the logic like this:

And it works! If I create two characters with a single controller - MyController_BP, they will go at the start of the game in different positions.
But when I create a controller through the code, they act as if they have single brain, go to the exact same point. Here is my controller code:

.h

http://pastebin.com/0xCvHBbM

.cpp

http://pastebin.com/uP2fvFt2

Thank you and sorry for my english :slight_smile:

Hello Syntopia, sorry for the delay.

That’s normal, if you have only 1 controller you can only control one pawn (by default at least). We could make a controller controls multiples pawn at once in certain cases.

If you create multiples controller, you can call MyController.Possess(Pawn1) etc…

what’s your goal exactly, each pawn has his own controller ? or a controller that controll multiples pawns at once ?

Based on what you said, it seems to be the first case, 1 controller has 1 pawn

So you should create multiples controller instances an assign a pawn to each of them.

I can make a code example if you want.

Just tell me what you want or if you have any problems to understand something.

Always glad to help.

gamer08

I solved this problem by transferring the global variables to header. C ++ is not my primary language, so I can not be aware of some of its rules. Thank you anyway!