How best to implement a punch attack

I have character animation and punches.

I can play punch animation easily.

The question is, how to detect a punch on an opponent?

What is the best way?

  • You can cast a line trace when the player attacks from the player to where it’s looking at and get the hit actor

  • You can cast a sphere trace where the the punch hits either by casting it on the location where the related bone is by using the “Get World Location” node or just use the relative location to the player if you can calculate where it’s gonna be manually, and then get the hit actor

  • You can detect when a specific bone of the player collides with the enemy’s capsule component using the “On Component Hit” node (enable the “Simulate Physics” checkbox on the details window of your assets to use this though, and also don’t forget to use the “Is Valid?” node with the question mark before checking the name of the bone after you detect the hit)

1 Like

Big question here is single player or multiplayer?

Singleplayer game