Trigger damage with hitboxes and collisions with the player

Here is how I set up my Alien to damage the player with a simple capsule collider.

  1. I first created a new Socket in the Spider Skeleton on the leg/limb that will be used in the animation (in my case - Left Leg)

  2. I’ve added a new Capsule Collider to the BP_Alien and parented it to the new socket (Scaled it a bit to cover more of the limb)

  3. In the Animation Montage, I’ve added two events - one to enable the collider + another one to disable the collider. Enable Collider is positioned right before the Limb/weapon begins to strike.
    Disable Collider is positioned right after it finishes the attack.

  4. In the BP_Alien, I’ve created two functions: “Activate Weapon” and “Deactivate Weapon.” They will be used with the events from our Animation Montage. To achieve this, I’ve used the “Set Collision Enabled” node like this
    Activate Weapon


    Deactivate Weapon

    AnimBP_Alien Weapon Event Functions

  5. Then, in the BP_Alien > Event Graph - I’ve added the “On Component Begin Overlap” Event for the weapon collider and added the “Apply Damage” function

  6. To make sure the weapon is disabled when we begin the game, I’ve also added “Deactive Weapon” to “Event Begin Play” like this

To test this, you can add Prints to all the new nodes/functions and test if they work as intended. Hopefully, if I didn’t forget or miss anything😅, your Alien should damage you ONLY if it’s weapon collider hit’s the player’s collider.

2 Likes

Pretty neat, I wonder which method is more common? I bet games like Kingdom Come use something like this. The method shown in the video seems like the “easy” way out. With this I imagine you could go even a bit further and do something like glancing blows where only partial damage is applied.

1 Like

Hmm, cant say what they use in Kingdom Come, perhaps it’s a combination of Ragdolls & colliders + something like this Did it hit - Trace Detection Plugin in Code Plugins - UE Marketplace

Probably, I´m no expert lol. I guess the one you linked is even more precise way to do something like that. Other games that do similar hit detection are the Mount & Blade series, it’s really cool. Was just thinking about a dungeon crawler yesterday where you would have to watch your weapon length so you don’t hit walls etc. to add more tactical feeling to combat.

1 Like

Privacy & Terms