How to get aicontroller from event beginplay?

Was following a tutorial for getting an AI enemy to use a behavior tree. The screen shot is from said tutorial which was done in an earlier version. I’m guessing since I am using 4.17 this part has changed. Any help very much welcomed.

That is now a pure function.

It can be called from inside a pawn.

212377-ue-answerpic35a.png

Though, I suggest for you to put that code in your AIController. Then just call Run Behavior Tree.

Right I was able to find those nodes just don’t know how to go about recreating the image I posted. I am still fairly new to UE4 and blueprints in general so a little more guidance is needed.

Everything compiles but still can’t get the AI to switch from idle to walking, not sure if the screenshot helps.

White lines represent to execution flow, they go from one task to the next.
Other colors represent variable data.

Drag the white pin from Begin Play, directly into Run Behavior Tree. Then drag the Return Value pin directly from the Get AI Controller node, into the Target input.

What does the blackboard look like?

A little more info, I’m working in 4.17 and in the side scroller template.

How would I go about doing that? I looked up debugging the black board but didn’t get much…

If you debug the blackboard, does it run?

Press ~ to open console and make sure in the separate window , that at the top you have an blackboard instance selected to debug

Not sure what you mean there…

Open the black board in a separate window

Start the game

Press ~ to open console and make sure in the separate window , that at the top you have an blackboard instance selected to debug

Now you should see the execution if it was setup right

nvm that, you got it working still.

So the blackboard is running! And your AI is trying to move. Do you have a navmesh for it to pathfind with? Press P to toggle navmesh visibility.

Yes the blackboard behavior goes crazy when I play, all the nodes are firing. But the Ai just stays in his idle pose. Pressing P does nothing probably since I dont have a navmesh for it to pathfind.

Been following This tutorail and got up to the 10 min mark before getting stuck.Don’t know if that helps any.

Alright so how do I tell the AI to stay in the Navmeshbounds?

BTW thanks so much for walking me through this! Really helping out a lot!

He’s staying put, because you don’t have a navmesh for him to pathfind on. So the MoveTo fails instantly, and it cycles through the other nodes and tries again.

In the Tutorial @0:14, you can see that his project has a navmesh bounds already in place.

The AI already knows not to leave the navmesh. That’s why he is not moving now. if you were to tell the AI to move out of navmesh he would most likely run to edge of nave mesh and get stuck or not move at all.

He doesn’t move because he knows not to leave the navmesh and if he was told to move he most likely would get stuck and not move? So how does that help, it was hard to understand what you are trying to say.

Navmesh has been added and had to rework the graph, he moves around the level but now the Ai character “pops” from idle pose to walking. And jumps around from point to point.

He’s saying, that AI can only move in NavMesh areas.
If the game tells the AI to move to a point outside the NavMesh bounds. Then the Ai will probably move as close as it can to the destination area, within the NavMesh.

Add a NavMesh to your level to allow the AI to know where he is allowed to move.

If that solves your issue, could you up-vote my answer, and mark it as the answer? :slight_smile:

So your problem is solved. If you have another question, you should make a new question.