Attempt to access BP, but BP is pending kill

Hi everyone, well my blueprint is working as I want it to work… but I am getting these errors. Please someone tell me how do I avoid these errors.

The Bullet Blueprint has only 1 static mesh component - ‘bullet’ , and I even tried destroying the actor in bullet bp itself but I was still getting the same errors.

Your issue is you are asking the engine to add the bullet’s location on tick to an array so every frame the bullet position will be collected and stored in that array. And the problem with that is, after you spawn the bullet, store it as a reference variable, give it an impulse, you wait 3 seconds and then destroy the bullet. Now once the bullet is destroyed the reference variable no longer has any valid data to offer to the nodes tracking its transform. Thus, you get the “pending kill” error. This is similar to the “accessed none” error which means the variable has actually been destroyed and now it is a “null reference”. Attempting to access data from a variable that is set to be “destroyed” will result in a “pending kill” error while trying to do the same thing with a null variable will give you the “accessed none” error. If you want to see examples of the accessed none error and how it can be fixed check out video #27 in the link below.

For your specific issue, change the order of the delay and “is valid” check. You check first and then allow 0.1 second delay where the object can be destroyed but after the execution has already passed the branch point and will continue on thus generating the “pending kill” error. Have the delay first, then after the delay check is valid and immediately finish the execution path, this prevents any discrepancy between when you checked the validity of the object and when you collect its transform data.

Thanks for the reply and the link, those surly did cleared some of my doubts but unfortunately I am still facing the error. alt text
alt text

This is gist of what I am trying to do… basically I want my character to teleport to a new position when I press the ability key again. (I know there are still some logical error/ other stuff that I need to work on) So… when I use the branch number 1 only, my code works like - (Presses key once) launch bullet, (second time) teleport, and then it resets the value. So, when I again press the ability key the bullet is launched and I can teleport again… and this works endlessly (though I am still getting errors). But when I am using Branch 2 or Branch 1 and 2 together, my code only works one time. I do get it now that I am trying to access a value from a variable that I am destroying and hence I am getting those errors… so I was thinking is there any way to declare a variable during run time? or maybe we can make a temporary reference variable that we can use to store value? or maybe an array?

  1. Why are you still doing the “is valid” check first then the delay? I am telling you this is going to cause issues either now or down the line haha
  2. A flip/flop node would be much simpler than the “DoN” counter and index method you have now. The flip/flop node first executes A then B then back to A which is exactly what you need
  3. If your goal is to have the player teleport to the location of the spawned bullet after a 3 second delay why bother storing its position each tick? A better method is:

Press Ability Button → spawn bullet → set 3 second delay
if (bullet exists when player presses ability button a second time) → get location of bullet → teleport player to position → destroy bullet
else (3 seconds has elapsed) → get bullet location → store location as variable → destroy bullet
when player hits ability button second time → teleport player to saved bullet position

I did tried placing Is Valid node after the delay… alt text

But using this is only making my code run 1 time… that is I spawn the bullet once and when I use the ability key (E) again I teleport to bullet location. But after that my bullet is not spawning again. And yes I don’t need transform array,(x.x) thanks for pointing that out.
By the way what I am trying to do is, even E is pressed we spawn a bullet/(figure) which will cover a distance and when we press the E key again we will teleport to bullet location. Even if we pressed the E key again after 1 second the bullet is spawned we will teleport to bullet location, and maximum time the bullet will stay is 3 second. So, if the bullet is destroyed (after 3 second) I need to spawn a new bullet and don’t wanna teleport. Yes, this is possible with Flip Flop, I just tried it, but there are still few more stuff I need to add with the ability key… so I think Flip Flop won’t work for me there. Though I was still getting these errors when I placed Is Valid node after the delay and was using Flip Flop…