r/unrealengine • u/TheVisualCast • 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
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.
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.