Melee System

screenshot5b

Getting some finished models and shaders into the game.  Still a few tweaks to make to the textures and then onto the rigging and animations.

Writing a melee system

The melee system was one of the first things I coded when I started working on this project and since that time I’ve rewritten it a number of times.  It’s something I want to be lightweight enough that 64 people can all be spamming melee attacks on the server, but still feel responsive and be relatively accurate to what you see on the screen.

While a character is idle nothing is happening.  Once the character begins a melee animation there are a few frames during the wind up when the weapon is being pulled back that nothing is happening, then the next set of frames during the swing the weapon is dealing damage.  Finally there’s a few frames of follow through after the swing before the character returns to idle or begins a second animation and melee swing.

melee1
During the damage dealing frames the weapon runs a trace between the handle of the weapon and the tip.  Anything that comes into contact with the trace between those points is added into a list of possible things to damage.  Then if the thing that has been hit is another player or building, on the opposing team, and hasn’t been damaged during this specific swing, damage is dealt and the hit fx are played on screen.

The damage dealing frames are played on both the client and the server but the server has authority and decides whether the hit was good.  The server also runs at a separate (and usually lower) framerate than your local client.  This is good and bad.  It’s good in that if you want to spin your behemoth around a few times as you land your melee attack it will only register a few of those frames.  So instead of absolutely everything around you taking damage it will be unreliable as to what it hits since only a few of those frames will play on the server and deal damage.  The bad side of this system is there is the potential for a frame that appears to make contact on your client would not be processed on the server and not deal any damage.

This is still something that I’m tweaking over time and trying to get the right feel for in game.  I’m debating adding some screen shake to hits and I really want to get some proper sounds and fx rather than the current placeholders.