Branch only works on false, please help

Hi, everyone.

I’m pretty new at using Unreal so hopefully this isn’t a bad question. Anyway, I’ve been following this tutorial for a top down shooter: - YouTube.
My issue is that when I use his setup, shooting and touching the enemy does nothing. I followed his tutorial to the best of my ability - I tagged the bullet, and even tried casting a bit (http://puu.sh/qkXHi/376d9e463c.png). When I set the branch to trigger when false, both shooting and touching the enemy prints the string, which I don’t want. I only want it when shooting. I’ve been going back through the video and scouring the internet, but I haven’t found anything. Thanks for helping.

Error message received when hitting enemies: Error Blueprint Runtime Error: Attempted to access Bullet1_C_7 via property K2Node_Event_Other, but Bullet1_C_7 is pending kill from function: ‘ExecuteUbergraph_BasicEnemy’ from node: Branch in graph: EventGraph in object: BasicEnemy with description: Attempted to access Bullet1_C_7 via property K2Node_Event_Other, but Bullet1_C_7 is pending kill

It looks like you’re deleting the bullet before you can cast to it and check it’s tag.

Most likely you have the BP for the bullet set to delete itself on hit. This is where you should do this functionality, not on your pawn.

Instead, on your Bullet, cast to other actor, and cast it to your pawn (or whatever you want to do damage too. You don’t even need to cast if you want to damage everything. Or, check if other actor has tag). Do Apply damage to other actor. Then delete self.

Then on your pawn, do Event Any Damage, subtract from health the damage dealt, set your health, check for death.

Then your errors should clear up and it should work.

Edit: I re-read your post and you say you only want your functionality to happen when you shoot - not on hit? if so, you shouldn’t attach this to “on hit”, you should attach it to wherever you’re doing the fire sequence.

Let me know if I’m misunderstanding and you still need help

Thanks for the feedback! But, what I want is for the bullet to come in contact with the enemy, the bullet to be destroyed (which it is doing), and then for the enemy to recognize it was hit buy the bullet (using a tag, which the bullet has), and then print that it was hit (only by the tag. But that is not happening). The screenshot I showed was on the enemy BP.

You can’t do it in that order. It can’t check the tags of the bullet once the bullet has been destroyed - that data has been deleted.

If you must do it on the character instead of on the bullet (and you should do it on the bullet, it’s much easier having it all organized in your projectile than putting it in every single enemy, but i digress) then you should call deleting from the character AFTER it’s done the damage sequence / printed the “I Was Hit!” string.

You can remove the “Destroy actor” From the bullet on hit, and just add it to the character after the I Was Hit string (drag off the cast to the bullet and do destroy actor)

But the proper way would be to have the functionality on the bullet itself.

Okay, what you’re saying makes sense. I’ll play around with it some more - still learning my way around this stuff - but so far stuff is changing for the better. Thanks for the help!
And, I have this on the BP for the enemy because I added inheritance for it, or whatsoever so I can make other enemies based on it.

Okay, I figured it out using what you said, but a little different. I put the cast and DestroyActor before the print, and it still worked.

I removed the Actor Has Tag and the branch. At the top of the image you can see the other enemies i was able to make from the BasicEnemy blueprit. Thanks so much for helping!!