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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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?


Product Version: UE 4.21
more ▼

asked Feb 10 '19 at 07:42 PM in Using UE4

avatar image

166 9 18 24

avatar image ThompsonN13 Feb 10 '19 at 09:56 PM

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.

avatar image leofucci Feb 11 '19 at 02:39 PM

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.

avatar image Shadowriver Feb 11 '19 at 02:03 AM

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.

avatar image leofucci Feb 11 '19 at 02:39 PM

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?

avatar image Shadowriver Feb 11 '19 at 09:58 PM

Granade a pawn? :p 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.

avatar image leofucci Mar 21 '19 at 09:20 PM

sorry I mean "Actor blueprint", instead of pawn.

avatar image Chyros Feb 11 '19 at 02:54 AM

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.

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

1 answer: sort voted first

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?

more ▼

answered Mar 21 '19 at 10:19 PM

avatar image

441 4 5 6

(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