Pending Kill From Function

I’ve seen this type of questions before, but not with my issue. Whenever I play the game and quit it, the log returns an error that says: Screenshot - 49b23ba9b971aabe8bda071df7547e9a - Gyazo

This is the blueprint from the AI actor where the error is.

This blueprints allow the AI to follow the player. Once the AI actor touches the player, then the player dies.

The easy fix is to add a “Is Valid” node from the Pawn node in the OnSeePawn event. Only if the Pawn is valid, proceed with the rest. This will clear the error.

Assuming you are quitting from a game state where the Leader and player exist. Also assuming that your error is generated by the quitting action.

My guess is that the callback for the AI move is being fired after part of the cleanup from quit has scrapped the casting to MainPlayer_C, which unreal then tries to access, but cannot due to the cleanup.

I’m no professional but that’s just what I see from the blueprint + your description

So, what can I do to fix that?

I would start by breaking your blueprint into parts until you can isolate where exactly the failure is occurring. Once you have isolated the point of failure, figure out what exactly in that card is causing the failure. Be as surgical as you can so you know exactly what is going on. The error looks to be caused by Unreal trying to reference a variable assigned for cleanup.

It’s returning that error because of “AI Move To”. I can break apart any of the blueprints from the “AI Move To” and it will work and not return the error. So, I’m not sure how exactly can I fix it so that the AI Move To still does its job.

Is this what you mean? Screenshot - b54aea902b5d595507883d189a28b79c - Gyazo
That didn’t work.

Now that I see it again, try to add IsValid to the Leader reference that goes into the AI Move To. Also, you dont need to add the actor reference and the location at the same time - you can pick just one :).

Let me know if this fixes the issue!

Screenshot - 971a5de33a9ea4e1268f6e94df6fc7af - Gyazo Is that how I should connect them? That didn’t work as well. I’m not sure but nothing is working.

I was trying to package the game into a windows app and it failed. So, I assume this is part of the error.

Also, what do you mean only have one with the location and actor reference?

You need to plug in the Is Valid node so it executes :slight_smile: Go from OnSeePawn → Is Valid → CastToMainPlayer.

What I mean is that you can just plug in Leader to Target Actor and disconnect Location. Or vice-versa. The AI will move to either a specific location or the location of a target actor. Right now you are providing both. Disconnect one and see!

Hey, that remove the error. However, the error is still showing when I try to package the game. It keeps failing.