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.
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.
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.
A moving ai behavior tree may appear not working if there is no ground with a collision capsule beneath it (and navmesh), solution - adding a simple collision to a static floor mesh.