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"

Does AIController destroy itself?

I implemented AI with my custom AIController class. I notice that for APlayerController, the game actually destroy the controller once the player exits the game. However, I haven't seen any example of destroying AIController, so I wonder how will it get destroyed (if at all) ?


Product Version: UE 4.7
more ▼

asked Jun 16 '15 at 06:20 AM in C++ Programming

avatar image

31 1 3 4

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

1 answer: sort voted first

It gets auto-destroyed along with the world it was created in, or when last reference to it goes away (like when controlled pawn gets destroyed).



more ▼

answered Jun 16 '15 at 08:41 AM

avatar image

MieszkoZ STAFF
7.3k 225 57 413

avatar image InfAdventure Jun 16 '15 at 06:14 PM


Thank you for answering. I just want to clarify on the last reference to it goes away. Does that mean it will be garbage collected?

Here is my scenario: I create a bunch of AI and have them spawn default controller with the custom AIcontroller class that I create. I play the game in the editor, and notice that the name of the controller is

AIController_1 to AIController5

Would the controller get destroyed if I press Stop on the editor ?

avatar image MieszkoZ STAFF Jun 17 '15 at 10:33 AM

Yes :)

If you don't do anything custom the default AI controllers will get garbage-collected one their controlled pawns "die".

avatar image Nerdballer Games Jun 13 '19 at 03:19 AM

Hi Mieszko,

The problem is that unpossessing and leaving it has a massive performance impact in a large scale game. We need a way of turning it off completely or destroying it. This isn't optimized:

alt text

To optimize AI in a large open world game, developers need a way to turn them off completely when a player isn't in range.

avatar image Bitwaker May 18 '19 at 12:39 PM

Does it mean that we should not call Destroy() on an AIController? (sorry if I'm bumping up an old question...)

(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