How to prevent damage to player while "blocking"?

Hello,

I have a simple Blueprint Script where a blocking animation plays when right-click is pressed, and the animation ends when right-click is released.

How can I make it so the player takes no damage while “blocking?” Script pictured below.

Thank you!

Hey @Telaspell!

You’d handle it where you apply / receive damage. Here’s an example:

“Target” is a reference to the target character that’s supposed to take damage (in this case the player). There are many ways to get a reference for the target! You could do a sphere trace on the attacking character’s hand / weapon and set our variable to the hit actor, or if only the player character’s supposed to be attacked by the enemy character class, you could just cast to the player character and save the reference, or you could also do an overlap check and fill our variable if our collision shape is indeed overlapping the player character, etc.

“StatComp” is an actor component where we handle our characters’ stats, and “Dec Health” is one of the functions inside the actor component that decreases the owner’s health. You can choose to handle damage another way though.

In my example above, we’re in the Event Graph of the enemy character, not the player. Though you can also choose to handle this inside the player character’s Event Graph, in which case you’d add our condition check in between damage detection (or hit detection, or whatever else you use) and damage application.

You can check out this tutorial if you like :blush:

Hope this helps! :innocent:

1 Like

Apologies for the late reply, but how would I plug that in to the damage system? I’ll have to wait until I get home from work to send over what mine looks like…really appreciate it.

Like I said, all you need to do is to add a condition before applying damage, regardless of however you handle it. If the damage is applied to the player character inside another BP, then you can just use your existing reference for the player character (you probably already do if that’s the case, but if you handle your damage system another way without using a ref to the player character, see the approaches I went over in my post above to get a ref) to access your bool type variable and plug it into the Condition pin of our Branch node.

Okay, I’ll see what I can do and get back to you…very new at this.

@VisAgilis In the mean time, this is what I have for the damage system. Not sure where I’d go from here. Mostly been following tutorials, I know a lot less than what it looks like lol. I need it explained like I’m 5.