r/unrealengine Dec 06 '24

pending kill "ruining" my BP logic. Solved

so on begin play, im getting all actors with a tag, making an array and applying a constraint to all actors in the array.
then in game i have a variable that sets the linear and angular drive of the constraint in a loop to that array.
so i can essenatily have a spring like effect, and turn it on and off.

ocasiuonaly when im going from 0 drive to 1 (for example) some objects dont react, unless they are "pushed/moved".

then when i exit play i get the obect X was pending kill or garbage, menaing for some reason that object is being recognized as destroyed or whatnot, and then its being removed from the array?
but why? and how do i avoid this, thanks!!

SOLVED: I added a wake all rigid bodies and now its solved

1 Upvotes

6

u/[deleted] Dec 06 '24

If there is a pending kill then you would have a destroy actor node in there. Unreal Engine has a "lifespan" setting that can be used instead of destroy actor. It's located in the actor BP.

1

u/TheVisualCast Dec 06 '24

https://preview.redd.it/ub4rvpotu55e1.png?width=1387&format=png&auto=webp&s=02a3b7540b5280fec7459470a362b9c1edc4af25

so, all the actors have lifespan set to 0 and there is no destroy actor.
this is all that's happening, but some of the actors arent respecting it, and just laying "dorment"

1

u/TheVisualCast Dec 06 '24

the do once is irrelevnt fyi

1

u/[deleted] Dec 06 '24

There has to be a destroy actor somewhere Pending Kill means the object is already garbage, but still exists somewhere, but it's about to be garbage collected.

1

u/TheVisualCast Dec 06 '24

def no destory actor involved...not that i can see anywhere.
unless gravity kills or destorys actors?

1

u/[deleted] Dec 07 '24

I'm not sure of any other way for Pending Kill to be triggered. According to Unreal Engine documentation it refers to an object that is already "garbage" but still exists somewhere. That was a copy and paste from their docs.

You could try changing the lifespan to 0.5 and see what happens.

5

u/TheProvocator Dec 06 '24

Physics go to sleep when idle for some time, I'm sure it can be disabled, but probably not recommended for performance reasons.

Should be methods for waking them up.

1

u/TheVisualCast Dec 06 '24

ok this solved it. i added a wake all rigid bodies in the loop, and its ok now.

3

u/DifferenceGene Dec 06 '24 edited Dec 06 '24

Do you ever set that object as a variable? Pending Kill errors usually pop up when you set something as a variable and then, later in your code, try to destroy it. That causes an error because the variable is now referencing something that is not in the game anymore. You have to make sure you are not setting the "object that will be killed" as a variable anywhere in your code.

Edit: reading back over your post, you are putting all the objects in an array. If that object is in an array when you try to destroy it, that's going to cause an error. You need to remove the object from the array before destroying it. You can't have any existing references to an object (in a variable or in an array) when you destroy it because now your code is referencing something that is not in the game. Make sense?

0

u/TheVisualCast Dec 06 '24

im not destorying anything...

im just driving a constraint, but its not driving it for all of the actors, and the error is making me assume its because of that error, it may not be tbh..

1

u/AutoModerator Dec 06 '24

If you are looking for help, don‘t forget to check out the official Unreal Engine forums or Unreal Slackers for a community run discord server!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/CloudShannen Dec 06 '24

Use a IsValid or Validated Get before using any Reference / Pointer to confirm it still exist and isn't Pending Kill etc

1

u/TLable Dec 06 '24

Can you create a class that is pending death and a state machine that when a actor is in that class, use a state machine to set what it cannot do in that state and do what needs to happen then pass it from that class to a dead actor.