Why do I get a runtime error when I call a Tag?

Hi Everybody!

I’m trying to get a basic enemy to only take damage from a the player projectile.

I’ve tagged the player’s projectile in the projectile’s Class Default.

109593-projectile-class-default-tagged.png

Also, I have the node checking for that tag.

But when the enemy is hit by the PlayerProjectile it prints the False string and the message log contains the following error:


Error Blueprint Runtime Error: Attempted to access BP_Player_Projectile_C_1 via property K2Node_ComponentBoundEvent_OtherActor, but BP_Player_Projectile_C_1 is pending kill from function: ‘ExecuteUbergraph_BasicEnemy’ from node: Branch in graph: EventGraph in object: BasicEnemy with description: Attempted to access BP_Player_Projectile_C_1 via property K2Node_ComponentBoundEvent_OtherActor, but BP_Player_Projectile_C_1 is pending kill


It looks like the Player_Projectile is being destroyed before being used, causing the “Is pending kill” message to appear. Look through what you are doing and make sure the Projectile isn’t being destroyed before you are using it.

Also, make sure that the Projectile Lifetime is set to 0.0, otherwise it can auto destroy itself.

That makes sense, I’ll check out my bp shortly.

I do know that there is a lifetime set to the projectile. The reason is it’s a side-scroller and I didn’t want the projectile to hit enemies out of screen.

Is there a better solution to prevent the projectile from going beyond the edge of the screen?

Use a Blocking Volume to block the Projectile and destroy it than, compared to an arbitrary amount of time (lifetime).

Oh that’s neat!

I’ve never used a blocking volume. I assume I must attach it to the Player Pawn?.. so it moves with him as he walks left & right.

Also, if I attach it via the Viewport on the Player BP, will it also enemies from making contact with player? I ask because I have Goomba-like enemies that will walk from out of screen and towards the player, damaging him when they touch.

I see the answer to my second question is Channels. So now I’m going to attempt to add a Blocking Volume to the Player and we’ll see how that goes lol.

**Kyle ** correctly pointed out the problem. Removing the DestroyActor Node from the end of the Projectile Blueprint resolved the Tag issue.

Thank you!!

The projectiles don’t fall or bounce. But the edge of the screen is not the end of the level. So the blocking volume needs to be dynamic and move with the character so that he can’t shoot out, but enemies can shoot and walk into the blocking volume.

After some searching, I couldn’t find exactly how to do this, so I’ve made a new thread.

How do I get a Blocking Volume to Follow the Player?: How do I get a Blocking Volume to Follow the Player? - Blueprint - Epic Developer Community Forums

I would just have it at the edges of the level (assuming your projectiles dont fall).

If they do fall / bounce, go ahead and destroy them with a lifetime but make sure to check to make sure the projectile reference you have is valid with the IsValid Blueprint node.

That’s fine, the projectile doesn’t have to end right at the edge of the screen. It can go for a while more before hitting the blocking volume