Download

[Request] Full Melee tutorial in C++/Blueprints

Hey All,

I have been playing around with Unreal Engine 4 and have the Unreal Engine official tutorials on making a punching animations using AnimMontage and such. I have been on the look-out for some solid start-to-finish melee tutorials that I could apply to my game but to no avail. Is there anything in the works or anything out there As I am attemping to make different weapon classes that have different properties but there are soo many ways to do it that sometimes I get lost trying to jump around.

Appreciate any responses!

Same here, I’d like to get a hand to hand fighting system working.

I got multiple animations to play and not cancel each other out so far, and some basic collision detection, but I’m struggling and it looks messy.

At the moment, I’m trying to figure out how to punch the other dummy, and have them react.

Using blueprint for now.

Indigenous almost has this working over the network. We were able to get running, punching, and dealing damage (and fighting in general) to work in single-player, but since Indigenous is a multiplayer game we’re revamping it (and the rest of our blueprints) to communicate between server-client.

We’ll post something (like our blueprints) once we have it working, though we can’t guarantee to spend a bunch of time explaining each step in great detail (we don’t have the time to spare).

I’ve been messing with the collision system for days and looking over the manual, but I still can’t figure it out. I get one part working, but then it’s wrong in some other way…, I’m lost.

should try asking on the Answer Hub, might get an answer.

Rama has a ‘VictoryGame’ that has some melee, ask him if he can give you clues to how he did it.

The way i implemented melee is simply Play a swing animation once the player presses the left mouse button and for the hit detection do a chain of traces on my weapon mesh from the top to the bottom ( using sockets ) , and if the trace hits another pawn then deal damage using the TakeDamage function i used one of Rama trace functions ( the one to trace against the Pawn Mesh ) so i could get pretty accurate tracing instead of hitting the capsule component

I’m trying to do a melee system and this sounds like it will do what I need. What I need is something that won’t hit the capsule and will give me feedback on what part of the character body was hit so I can pass it into the TakeDamage event on the character but I have a couple of questions on this.

Where can I find this trace logic that Rama wrote?

How do you just trace between sockets and if you’re using sockets does that mean your weapons are skeletal meshes?

Rama’s plugin has a BP node for tracing for bones and it is very efficient. You get the hit result from the trace and it will give you the closest bone to the location it hits on the mesh. The plugin’s thread is here: (39) Rama's Extra Blueprint Nodes for You as a Plugin, No C++ Required! - Blueprint Visual Scripting - Unreal Engine Forums!

You use sockets as start & end locations of the trace. And no, it doesnt have to be a skeletal mesh, you can create sockets for static meshes as well in static mesh editor.

I got a qustion for you all, and it may be stupid.
I made my melee weapon system the way that my weapon hits the actor and the actor checks to see if it actualy was a weapon.
And then deals damage, i use no trace only the generated hit event, is this a bad idea?

Ah!!! has sense! thank you very much for the help.

Now I have a couple more questions if you would be so generous as to answer them for me.

Do you do the trace on tick? I’m doing it on tick and I have a filter to know when the player is attacking so i’m not tracing every tick, just on attack ticks. But I am noticing that it hits a lot during the swing… and I mean a lot! I get about 50-60 hits/swing. That’s ok, I just need a filter. Do you have any advice on a filter here?

Also, since you are using socket, are you doing multiple traces then? I have two sockets along the blade of my weapon but if you had a more complex weapon that could have more than one it might have a more complex set of sockets (meaning more than just the two). I guess what i’m getting at is, is there a clever way to make a sweep with several sockets?

Yeah, you can do it on every tick but only when you hold the button and swing the sword. That plugin trace gets too many bone names since it gets the “closest” bone, so if you slice right through the enemy with a good swing animation you may get more hits than you need. To limit the hit bone output, you can use a timer with a custom event if you want to trace less or you can compare the hit bone names with main bones of your character(like head, upper arm, lower arm) and make a bool array with those comparisons and then use that bool to for a branch to open only when those bones are hit.

No. For a single handed sword you dont need more than one trace(you can use 2 for a double edged sword if you want more precision) and as i said earlier you use one of the sockets for trace start and the other one for trace end locations. By complex set of sockets if you mean a weapon like mace, you may want to use sphere trace. And for a long sword you can place several sockets along the blade and do traces from those sockets at swing direction.

These are my experiences from the last week so dont take them as absolute truth and do your own experiments on top of those to get the best thing for your own project. :slight_smile:

How would making a mount&blade:warband solution work? Could it work out having just a stick sticking out of your hand and have collisiondetection on the stick?

That said, Rama’s plugin looks awesome tho :slight_smile:

I dont know how it works. Can you post a video please?

Mount & Blade is mostly about the animations and picking one based on inverse mouse movement (or regular mouse movement/direction).

So you have these animations:

  • Stab down/forward
  • Chop downward
  • Slash left
  • Slash right

I think that M&B uses physics volumes and hit events, probably, because you can hit multiple enemies and such easily, which is a little trickier when using a trace-based melee system. If you want to go that route, you’d basically just set a trigger volume up that encompasses your melee weapon, and then do damage on hit events.

After that it’s just a matter of priming which animation to play based on the inverse (or regular) mouse movement direction. E.g. (for inverse) if the player is panning the mouse to the right, play the leftward swing, if left, play the rightward, etc.

This is duel-version of mount&bladehttps://youtube.com/watch?v=WG0YM35goSE
Team-combathttps://youtube.com/watch?v=uY3XNwVHShE
Not sure if you meant videos of how the programming works, but like n00bsaibot said, it’s cylinders (or sticks) sticking out of the characters hands. You can’t hit multiple enemies tho is what i’d like to edit in his post.

Would it be un…effecient for me to change the weapon to a physics object and just check the collision seems like would give better control for what we are all doing. I like skill based games where your skill defines you not your level so i like to make combat that fits as such.

I’ll drop in a link to my series of melee tuts…

should be able to recreate my game on how I hit enemies…I use the Capsules for hit detection but you could easily activate the Rama’s Trace system instead of using the Capsules collision channels…if you didn’t quite catch that just watch the videos and you’ll understand it…
I should have some new videos up soon…

Good luck…I always love seeing new Melee fighters here on the forums…