What would cause Behavior tree no to execute?

So I am setting up some very simple enemy AI using Behavior tree. I have done some reading and followed a tutorial to get it set up, so that I can then experiment with/learn the system better. I have the Behavior tree and the Blackboard setup. I also have a blueprint setup to execute the BT task on event begin play, as well as a blueprint to set the player’s position for use as a key.

When I look at the Behavior tree while I’m playing, I can see that the player position is being updated as I move the player. The enemy is supposed to then “move to” the player’s location using this info ( a key called playerposition ). When I hit simulate the enemy does as I intended and moves to the player. However when I hit play and start the game nothing happens.

How are you spawning the Bot with the BehaviorTree on it in game?

If you use the node, it’s called something like spawn from AI, or spawn class with AI. You can set the BehaviorTree in it and it will initialize it.

Otherwise you will need to activate the BehaviorTree yourself, easier just to use the node since it is working now.

In case I didn’t mention before. When I hit simulate, the Behavior Tree functions. It does not function however when I actually play my game. I have watched the player position vector in the Behavior Tree while in play mode, and it does in fact update with my player’s position, but then the move to is not executed.

Can you show your BT ? What you mean nothing happen, is BT not run or you have some condition that block “move to” task ?
Btw, i think you can set the key as the player pawn, so you no need to update the player position.

If the BehaviorTree is activated, just place a composite node under the root and wire your task to that. It will play.

You don’t call into the BT from external Blueprints to activate nodes, put the flow for that in the Tree itself.

use a blueprint to activate the BT task

What do you mean by that? What function are you calling?

So this is what I have

Here is the Behavior tree/ AI controller

Try using the Spawn AI Actor Node, you don’t need to call run on the BT. Post of pic of your Behavior Tree also. Where is that function that you show?

I put up a pic of the Behavior Tree, its linked right under the AI controller. I’ll try putting in the node you mentioned. What function are you asking about? The AI controller is a BP/AI controller class, I have the enemy pawn’s AI set to use that. The Player position is a BTTask blueprint, you can see in my Behavior tree that it is a vector on my blackboard I’m using to track the player position.

Sorry, thought the links for the pics that were displaying.

You can set BlackBoard values in Tasks, but you should really make a Service Node to do that, then set the time on it so it’s not every tick.

How are you spawning the Bot that this Tree is on? You do not have to do the step you did in the CubeEnemyController. The spawn node will set it, or just place the character in the level should be fine.

Yeah, I have just been placing it in the level for now. If I use the spawn node, what would be a good way to set the location where I wanted it to be spawned?

I had a similar problem.
I had to find the ‘Pawn’ tab in the details window for MyAICharacter actor in the World outliner and make sure “AI Controller Class” was set to MyAIController class.
For some reason, despite being set correctly in the BP editor, when I place the actor its AI controller is reset to the default AIController class.

1 Like

Dude you saved me, i was going crazy and the problem was exactly the one you indicated, thanks!