Does pawns get automatically killed?

So i´m experiencing some strange behavior that is breaking my head…

I have a grenade, which has a name. I save an instance of this grenade into a variable that is never modified/used/deleted/throwed or anything, also I have a user widget which shows on screen grenade name from this particular variable.

What is happening: After random amount of seconds (I chronometed this, always above 1 minute) this particular instance throws this error “Attempted to access GrenadeInstance but is pending kill”…

At beginning I thought It was because some mistake on my code, where I throw grenades… but no, If I press play, and keep everything still, it happens the same, so this looks like a garbage collector feature here, also Im sure im not using LifeSpan, there is no reference to lifeSpan, besides as I said, it is randomly being killed.

Is there something that unreal does to automatically kill this kind of pawns?
If so, is there a way to prevent this to happen?


no there is no feature that auto kills pawns. the issue is probably in your script. show some screenshots so we can see what youve done.

besides as I said, it is randomly being killed

in programming nothing is ever random.

There is garbage collection of all UObjects and any UObject that is not refrenced any external property will be considered trash. Things is Actors never get garbage collected because they are always atleast referenced by UWorld object, as long as they are in the world they wont be collected

Can describe what GrenadeInstance actully is? is it UObject in any way? It can be be potentially collected.

Also, we haven’t seen your code yet. But make sure your Grenade variable has a UPROPERTY flag. As long as the Actor that holds that UPROPERTY variable is not marked for GC, your Grenade should live on.

It´s a Pawn, as far as I know, Pawn at some point inherits from UObject. Based on your answer I was wondering if maybe I forgot to put the “owner” or “instigator” pin, making this instance not referenced by anything, but the owner is set with the player character. this instance in particular is created server side, variable has replication ON, Could this be also a reasson?

In the world nothing is random my friend, you just don´t know the variables involved.

If you try two times with different result, it is random.

Granade a pawn? :stuck_out_tongue: kind of wierd. All actors (pawn is actor) should not be deleted as they always atleast refered by UWorld objects. So my guess is there something else deleting it.

sorry I mean “Actor blueprint”, instead of pawn.

Pawns will only be destroyed if they are unpossessed, manually destroyed with code (DestroyActor) or they have fallen out of the world.

One way you could test this is by moving your grenade variable to the player controller, if the error persists, then it is a problem with your logic.

When you say you “save an instance of this grenade to a variable”. How are you actually setting that reference?