I can't destroy an actor. Why?

I have “AI” object (class inherited from AIController) in my “NPC” class which controls behavior of my NPCs. When an NPC dies, i want to destroy this object, but it seems indestructible! I call Destroy Actor on it, but it still ticks every frame and does all the logic no matter what forever. I know that objects on Destroy Actor are marked as pending kill and destroy later (next frame?), but this one doesn’t destroy at all. Every “AI” object of every dead NPC is still visible in World Outliner. What can cause this?

I’ve tried calling UnPosses before Destroy Actor, creating a function “DestroyAI” in “AI” class and calling Destroy Actor there, but it didn’t helped.

This is why (from the UE4 source):

void AController::K2_DestroyActor()
{
	// do nothing, disallow destroying controller from Blueprints
}

To get rid of controllers, you need to disconnect the “player”/controller from the game on the authoritative server. Usually you can do this from your GameMode Blueprint or C++ class.

Oh, so that’s why… Thanks. So I’ve created “DestroyAI” function (with AIController parameter) in my GameMode blueprint and call it from my dying NPC, but it still can’t destroy it :frowning:

It’s just a DestroyActor node targeted to this AIController object, so yeah… But my “AI” object is not a player controller, but AI controller, so i don’t know how to destroy it by other node than DestroyActor.

I have a little unusual AI setup, I didn’t used behavior trees, etc, because they were bugged back in 4.6… So in my project every NPC spawns its own “AI” blueprint (derived from AIController) in Begin Play which controls him - Well, maybe I should rework my AI setup somehow, if destroying these is not possible…

Can you post an image of it? You need to be using the nodes that are for adding or removing players from a game, not for simply destroying the controller object (which would result in breaking the game, if it allowed you to do it).

Yeah, but AAIController in UE4 derives from AController, which you can’t destroy from Blueprint (and if you destroy it manually from C++, your game will break). You should be able to remove the controller by removing it from the game, though, using the nodes related to adding and removing players, if I remember correctly.

Ah, sorry about that. Maybe I’m wrong. I’ll have a look later when I’m less busy if you haven’t figure it out by then.

I’m searching for the nodes you’ve mentioned, but i can’t find any for removing players/controllers from game :frowning: