Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AI behavior tree stops running after changing controlled pawn

I have a problem and as always it seems to be like a bug, because it worked in 4.7 and is not working in 4.8.

I have a behavior tree, looks like this:

alt text

So it's always running the UpdateBuilding service once a second. The service looks like this:

alt text

So it prints out "TickUpdateBuilding" every tick. Really simple.

Now I do this:

alt text

I detach the pawn from the AIController, delete the pawn, spawn a new pawn and attach the new pawn to the old AIController. And now the behavior tree stops to run, or at least I stop seeing "TickUpdateBuilding" in the log. In 4.7 it worked without any problems.

If you have a workaround for this until it is fixed (I really hope for a 4.8 hotfix), please let me know. This changing of the pawn while the controller stays the same is the core element of my whole AI, at the moment it's doing nothing, so the whole game is not working.

Product Version: UE 4.8
more ▼

asked Jun 13 '15 at 11:24 PM in Bug Reports

avatar image

John Alcatraz
1.3k 57 139 125

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

This is by design - when a pawn is unpossed its controller's logic get's cleared up. The fact that it was working pre 4.8 was an oversight.

There are two things you could do to address that:

  1. Call RunBehaviorTree for every newly possessed pawn.

  2. Override AAIController::UnPossess in your custom AI controller class to bypass the logic-clearing code you don't need.



more ▼

answered Jun 15 '15 at 10:02 AM

avatar image

MieszkoZ STAFF
7.3k 223 57 412

avatar image John Alcatraz Jun 15 '15 at 04:19 PM

Thanks for the answer, but why did you change this? It's making my whole AI not work... Did anyone had problems with the way it was before 4.8? If I would want to make the controller reset everything I could just destroy the AI with controller and respawn the AI with a new controller... So before 4.8 I could achieve both behavior, and now I can't and you say this is by design?

I tried to override the function but I can't find it in the override menu:

alt text

Only OnPosess, but not UnPosess. My project is blueprint only, I can't do anything in c++.

The important thing for my AI is that the behavior tree is not changing it's execution, so if it runs a certain task before the pawn changed it has to run the same task after the pawn changed, and most importantly all the blackboard variables need to be 100% the same as before. If I just call RunBehaviorTree on the new pawn this is not the case, right?

I have also tried to not call unposses at all but only possess the new pawn and then destroy the old pawn, but this does not fix it, the behavior tree still stops running.

Please tell me how I can make my AI work again... :(

avatar image MieszkoZ STAFF Jun 16 '15 at 09:25 AM

The reason it has been changed is that it was causing dead AI to have active brains.

It seems there's currently no way of doing exactly what you need via Blueprints. I can make a quick C++ fix for you if you were willing to compile your binaries from UE4 sources on github.

However, maybe you don't need that at all. What's the use case for needing BT to continuously run while you switch the controlled pawn? I mean, we can't really support it out of the box in a generic case. For example, this would break the behavior if you switched pawns while currently controlled pawn was performing a Move task. Due to the implementation details it could recover, but "new" pawn would not get a new behavior until the previous one finished the move.

Tell me more about your setup, please.

avatar image John Alcatraz Jun 16 '15 at 06:18 PM

I have no problem with compiling from github, but the problem with such a fix is that it will only work for the current version, right? After 4.8.1 is out it would no longer work and I would have to either use the old 4.8.0 with the fix or 4.8.1 without the fix.

I have written you a detailed explanation on how my AI works in a PM in the forums.

avatar image MieszkoZ STAFF Jun 17 '15 at 09:24 AM

No fixes are made specifically for UE4 sub-versions, the fixes are always done on the master branch, so if you get sources from github then you'll also get whatever fixes are being made for issues found in current UE4 release. You'll also get possible bugs that have been introduced in the meantime. It's not ideal, I know.

I'll read through your description, pick the best fix and get back to you.

avatar image leobelmontLu Dec 12 '18 at 07:06 AM

I have the same problem,You can monitor the onPosess within the blueprint and reread the behaviortree, which I guess looks like this. So I'm trying!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I have the same problem,You can monitor the onPosess within the blueprint and reread the behaviortree, which I guess looks like this. So I'm trying!

more ▼

answered Dec 12 '18 at 07:02 AM

avatar image

1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question