attempted to access component but it is pending kill
When the AI gets hit by the bullet projectile, it takes damage to health and if it dies, Destroy the hitbox component, plays death animation once and after a 1 second delay the whole actor is destroyed.
AI has 100 HP and each bullet takes 40HP away. When testing it, sometimes works, registering 3 bullet hits (just enough to kill) even if I keep spraying my weapon. Other times, even after the hitbox component being destroyed (i toggled in game visibility for troubleshooting) and I keep spraying the gun, it keeps registering bullets, for whatever reason. Then after it shows those error messages.
The issue here is consistency. No event tick is involved in any of this, plus performance is steady at 120 FPS. I don't know what else to do.
asked Apr 20 '19 at 09:39 PM in Blueprint Scripting
Its probably because multiple bullets are triggering the event in a very small amount of time so they sometimes trigger at almost the same time and call the destroy component node more than once. To counteract this, you could simply move your do once node to be directly after checking if health is less than 0.
Furthermore, you should probably check if the health is below 0 before applying damage since it doesn't make sense to take away health from a dead target.
Lastly, if moving the do once node does not work, check if the collision box is valid before calling the destroy component node on it.
Let me know if you have any questions.
answered Apr 21 '19 at 12:41 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here