# If I design a game that has both guns and melee weapons, how do I make them equally viable?

I have a plan to make a 2D action platformer game, and I've started prototyping a bit in Godot 2D. My intention was to make the character fight with both guns and melee weapons, with gunplay like the Metal Slug series and melee mechanics akin to what's found in Dead Cells.

The gun would be bound to the right mouse button [as a secondary attack] and the melee to the left mouse button [as a primary attack], though I do plan on making it so that the player can switch their primary attack type.

The gun used and the melee weapon would be different per character - one would have a high caliber revolver and a greatsword, while another would have a high RoF assault rifle and a knife, for example.

The basics, I get (right now I use a free game art sprite set, and I can use the frame number in the animation to fire a bullet or enable the melee attack hitbox).

It's the balancing issues that got me stumped.

I want to make both ranged and melee combat viable, or as close to equally viable. Though, with the existence of guns, I'm not sure anyone would want to use the characters' melee weapons.

I know it's possible to make guns and melee weapons fulfill different functions, like guns only able to attack one target at a time (except shotguns) with varying fire rates, while most melee weapons are able to attack faster than guns but with a much shorter range, or able to attack multiple targets at once within its hitbox but much slower than guns.

For example, make the melee weapon have a large hitbox and able to apply some non-elemental Damage over Time but with low damage itself [and, when charged, able to pull an enemy in front of the character], and the gun a quad-barreled shotgun that delivers massive damage at close range but with long cooldown.

Would that be a viable option to make both melee and guns equally viable, and are there other ways to do it?

• This comment off topic, just want to say: do not forget accessibility. Jun 1 '18 at 18:12
• @Theraot I don't think that comment is off-topic at all. It's well worth considering accessibility when designing mechanics. Some choices for balancing melee vs ranged will work differently for different players - eg. tuning highly twitch timing such that the use of the two options presents an interesting strategic choice for you might make it so that I can't successfully play with the melee weapon at all. I think it's worth sharing an answer with some accessibility-focused options, or configurable settings to offer to help balance for different kinds of players. Jun 1 '18 at 22:17
• @DMGregory fair enough. Jun 2 '18 at 6:45
• MOBAs may be a good study target for this. In Dota 2 for example, melee heroes typically have more base health, armor and attack damage, and more frequently have abilities that reduce incoming damage or let them escape a fight more easily. Many in-game items' effects are also stronger if wielded by a melee hero.
– Anko
Jun 2 '18 at 7:09
• Ranged has lower damage, melee has lower range. Both sides have valid strategies. Ranged fighters can kite. Melee fighters can close the gap. Or, if you want guns that pack more of a realistic punch, compensate by making them realistically bulky, difficult to run around with, and difficult to aim while running. Jun 4 '18 at 7:39

There's many different carrot/stick approaches you can use to solve this problem, more than I can list in an answer. You'll have to play around to feel what work best for your game.

1. Ammo System - your gun has limited ammo. You can get more ammo by killing enemies or attacking them in melee. Maybe the gun has a long reload time so it's better to shoot off a salvo and then close in for melee. Maybe you need to move forward to pick up more ammo crates so you need to make efficient use of ammo and melee while pushing forward so you don't get stuck completely ammo-less.

2. Make the gun unable to work at close range - This incentivizes the sword-user to close the distance as fast as possible, while the rifleman needs to figure out ways to maintain the distance. Meanwhile, the knife is still useful to finish off weak enemies that get too close if you've softened them up with the rifle

3. Make the melee weapon do more damage - raise the numbers up to the point where the player wants to close into melee range

4. Make a variety of enemies with different weaknesses - That big scary ogre will smash your face in if he gets in melee range, maybe we should shoot him from afar? The goblin archers die in one hit in melee, but are hard to hit from range because they hide behind trees.

5. Score the player on variety - kind of blunt, games like Devil May Cry just tell the player they're awesome for mixing up different combos and tactics.

6. Have different mobility options - The difference in range requires the shorter-range combatant to close the distance. Having a variety of movement speeds and movement/CC abilities helps differentiate ranged vs melee combat. Generally, the ranged player should be less mobile, or otherwise they will be able to kite the melee character around forever.

7. Have the weaker option provide CC (Crowd Control) - the melee guy can use a gun to cripple a target to make it easier to chase down, the ranged guy can use a spear to hold an incoming attacker at spears-length for friends to attack

• Another technique I've spotted (not enough to merit a separate answer, I think) is making melee attacks drop health/powerups, to compensate for the increased risk at close range and/or motivate a risk-reward gamble. Jun 1 '18 at 18:24
• Not worth a full answer of my own, but also important 8: Map design - wide open spaces will promote gun battles, where tight enclosed spaces allow melee to be much more effective. Jun 1 '18 at 19:36
• You can get more ammo by killing enemies or attacking them in melee. from #1 is a fantastic suggestion. DOOM (2016) used that tactic as well as #3 to make melee combat an extremely viable option. And #9: If you make the melee kill animation really fun, players will naturally gravitate towards that. Jun 1 '18 at 22:03
• For those not familiar, CC stands for Crowd Control. This usually come in the form of stunning or slowing another player. Jun 2 '18 at 15:19
• @TOOGAM Why not? Because it is not fun. As a player I don't care about the logic behind your features. If it is not fun, I won't play your game. Jun 4 '18 at 0:15

• risk of collateral damage. You don't want to fire a shotgun in a hot air balloon, or around oxygen tanks, or near fragile treasure or the NPC you are trying to rescue
• stealth. The classic "strangle the sentry" is the most obvious example.
• proficiency. Present the player with weapons that take skill or time points to master.
• critical failures. Your fists never explode.
• No, fist don't explode but they do break :P Jun 1 '18 at 23:16
• Your fists never explode ... well, I guess not literally anyway ... Jun 3 '18 at 21:15

Another option I've not seen mentioned is this:

Allow the player to reflect or destroy projectiles with melee weapons.

Albeit unrealistic, sending a deadly bullet barrage back into the enemy's face with your trustworthy {baseball bat | katana | lightsaber | frying pan | ...} feels both "cool" and rewarding, and can provide a good incentive to use melee weapons without making them overpowered in terms of raw damage output.

Nuclear Throne and Ubermosh use that mechanic to their great advantage.

• Pulling in an anime reference, Gun Gale Online had this, and no one used it until the Gary Stu main character showed up. Jun 2 '18 at 1:44
• Genji in Overwatch has a reflect ability like this. He is a lot trickier to kill for most ranged than most melee, since he can reflect projectiles. Jun 4 '18 at 9:17
• @Draco18s To be clear for future readers, that's not the same show as SAO II, where they go play a game by the same name, GGO. Jun 5 '18 at 14:04
• @Draco18s Oh, I thought you were referring to en.wikipedia.org/wiki/… Jun 5 '18 at 15:28
• @TylerH Yep, figured that out when I did the le google. Added it to my anime watch list. :) Jun 5 '18 at 17:12

## TL;DR

• Carpal Tunnel Syndrome is a thing. Avoid repetitive smashing buttons.
• Improving accesibility will help everybody (Curb-cut effect).
• Do not think of accesibility options as cheating.
• Allow to change keybindings. If possible, multiple keybindings for a single command. If possible, across multiple input devices.
• Allow melee to do something that ranged attacks cannot do.
• A command is not a verb. Think in terms of verbs, not input commands. Well, actually, both.
• Construct combos instead of botton smashing.

Other accesibility settings:

• Target snapping while aiming.
• Auto aiming. For peole who do not have mouse, or do not have good aim.
• Slow game. For people with slow reaction timing.

Note: you can change your scoring system or even disable it (and archivements if you have them) when using these settings.

## Introduction

As game developer you should be able to put forth the vision you have for the game. And that vision can include making it difficult.

In favor of allowing more people to enjoy the game, I would like to interest you in the idea of assit mode. Not really related to the melee and ranged problem. So have a video: What Makes Celeste's Assist Mode Special | Game Maker's Toolkit.

Sometimes the distinction between a diffulty setting, an accesibility feature, and a cheat, is a matter of presentation and culture. After all, in the lack of proper accesibility features, people may turn to difficulty settings or cheats. Do not be condescending. A player with a disability does not need to be labelled a cheater, or be mocked. By principle of giving the same experience to everybody.

## Carpal Tunnel Syndrome

Carpal tunnel syndrome is - in my opinion - the most relevant condition for this case. In modern office work, it is often associated with the use of the mouse. In particular, fast clicking for long periods and improper posture. It will also happen with the keyboard.

While, arguebly, people should be taking measures to prevent the syndrome (which may include using wrist support and not playing your game), it is preferible to make your game accesible even to people who have it. By the (Curb-cut effect), we will be helping others that do not have the condition. I will not elaborate on how, brevity eludes me, and this answer is already long as it is.

We want to:

• Spread the work, so people are not pressing the same key all the time.

To do this, it is useful to balance melee and ranged attack. However, that is not the only thing we will do. We will also allow the player to remap the keybindings.

• Avoid the need for quick repetitive input.

To do this, we need to stop thinking in terms of input commands. This will not only mean less click-click-click, but will also open to you the posibility of structured combos.

Another thing you can do, is have the option to slow down the game (not as a power up, but as a setting).

• Give natural exit points, so people can put down the game.

This, of course, is not directly related to the melee and ranged problem. So, have another video: Exit Points - Putting Down the Game - Extra Credits.

## Mechanical balance

Evidently, melee weapons are not useful at range. This means they got to outshine ranged attacks at short distance. The issue is that ranged weapons would be effective in close combat.

What we want is to make the melee weapon faster. I want you to think in terms of speed. Not fire rate, mind you, but dead enemies per second.

How do you do that?

Better melee:

• Melee is stronger (more damage = more kills).
• Melee can do combos. No, no click-click-click. Go read about Verbs below.
• Allow a single melee attack to hit multiple enemies (possibly stunning enemies, probably with low damage per enemy and potentially with high damage per attack - adding across all enemies, and may kill multiple at once).

Handicap ranged attacks:

• They have spread and recoil.
• Ranged attacks are slower (low fire rate => less kills)
• Ranged attacks use wind up (like Mega Man, or like a bow, or like Futurama Fallout 4 laser guns)
• They require ammo.

But that is thinking insde the box. Numerical differences only go so far. I would like to advocate for diffences in kind, in particular incomparable differences in kind.

Even if melee is perfectly functional, then comes ranged attack that can do all that melee can do, and also works at distance... Melee needs to be able to do something that ranged attacks cannot do.

Of course, combos. However, let us be creative consider some tropes:

## Remap keybidings

The gun would be bound to the right mouse button [as a secondary attack] and the melee to the left mouse button [as a primary attack]

No. It is NOT good to hardwire acctions to pre-defined keybinding.

You should allow players to rebind these. At least to the keyboard, to game pad if possible. In fact, I will advice to allow to map commands to two different bindings. That way, I can have a way to do them with either hand.

Futhermore, if you can allow to spread bindings across multiple input devices (something that few games do), this will not only help people with carpal tunnel syndrome. It will also help people with other disabilities, for example, if you can only use one hand or if you need to play with your feet.

Given that you have bound attack to the mouse, and given this is an (action) platforming game. I am guessing, that you have bound input to ASDW or to cursor keys. Those should be configurable too.

I also suspect you aim with the mouse. Thus, some options to consider are aim snapping and auto aiming. Yes, I know that makes ranged attacks better, we will balance it, Ok? Ok.

## Verbs

Let me talk you about verbs.

What is a verb?

A "verb" is an abstraction of the physical interaction with the input device. There is an actual physical interaction (pressing a button, for example), and you get a representation of that in your game. We want to disassociate that representation from what the physical interaction actually was (we do not care what button you pressed, just that you did the thing that you configured the game to recognize). That way we abstract the input, and that is how we get to a verb.

We will label the verb according to what it is intended to do (and that is what we tell the user they are configuring). Therefore, we can say that we have a verb to "jump". However, the verb is not the action; in fact, it is not the command.

In some games, you have one to one relationship between verb and command. In addition, when that happens we can treat them as the same thing. However, commands can be composed of multiple verbs.

Furthermore, verbs may not be discrete. For instance, these inputs we can understand these as different verbs:

• Press a button
• Hold it for a given amount of time
• Release the button

Alternatively, they might be the same verb. That is up to the game.

Addendum: While a command can be composed of multiple verbs, it is also true that a single verb could translate to multiple commands. For example, holding a button could translate to repeated commands to fire.

The advantage of verbs is that you can program how verbs are executed disasociated from how you input them.

First, let us consider the action "run" (as in, moving fast: sprinting, running, jogging※). There are a few common solutions:

• You hold a key to run, and the direction you want to run. (Key combination)
• You double tap the direction you want to run. (Double press)
• You hold the direction, and after a short while, the avatar start running. (Hold over time)

Some games will have you tapping a botton, or even alternating tapping two bottons to run. Those are not common.

※: Not claiming these to be the same, but whatever you have in the game.

The linked video above will expand on "jump", but I want to mention that there are two common conventions for jump: using the vertical direction, and using a dedicated key. The correct approach is: no matter. You should be able to map these however you want.

Verbs become more interesting when you can mix them. With these two you already have the running jump, and the double jump, and with enviromental context you have wall jumps. But, let us talk about attacks...

Melee attack verbs

Here is something that ranged attacks cannot do...

Evidently, there will be a key for melee attack. A common command is the rush attacks (a.k.a. consecutive normal punchs), archived by pressing the attack key repreatedly. I need you to think in terms of verbs. This is not attacking fast, this is a different kind of attack, which is often reached by quick presses.

However, the animation does not have to be one hit per press. And you do not need to require the player to press faster for better damage, instead you can require the player to keep a particlar rhythm, and the higher the damage the closer you match the rhythm. The attack would end if you fall off the rythm too much (or simply stop pressing for a short while).

Other combinations of verbs:

• Jumping attack. It can take a different form, some common versions are a diagonal doward kick and a spin attack. You can have both: Jump + Attack = spin. Run + Jump + Attack = kick.
• Running attack. Usually a dash.
• Holding attack. Could be blocking attacks, could be charging. Could be both, for example, each blocked attack adds to the damage of the attack you do when you release.
• Slam attack. Smash the grown, hits nearby enemies. Usually Jump + Down + Attack. Some games just use Jump + Attack.

Also, consider context sensitive moves. I have already mentioned one: finishing an unalerted enemy.

So, one context to consider is the state and distance of the enemies. In that example, an unalerted enemy can be finished in one hit. However, an alerted enemy gets a regular attack. What if the enemy is attacking? The melee attack could knock down their weapon (parry/unarm/steal weapon).

Another context to consider is what you where doing before the attack. For example, a quick change of direction before (in a small time window) the attack can be a different attack. Being something you would in when surrounded by enemies, this can be a ground spin attack... It could even be different if you were running or not. For example, it can be a ground sping when not running, but a backflip when running, it could even push enemies up to air if they are cough infront of the backflip.

Addendum: Also consider quick time events.

Melee ammo

Some attacks may have a resource. Although, it is often the case that ranged attacks require ammo. Some special melee attacks could have their own resorce. That way, when the player has the resource, will want to use melee (or may want to save it for a difficult battle).

You can put special attacks on a hit counter, so that you do not use them all the time. That is, you load up your hit counter before being able to use the special attack (thus, arguably, the hit count is a resource).

It could be the case that you want to load your melee hit count to have the attack ready before entering an area, encouraging the player to use melee in the previous area.

Combos

There are three common approaches for combos:

• Pressing buttons fast. Please, don't.
• Timing. This is ok for the rush attack. It will not work well for other things because it becomes a waiting game.
• Mixing verbs and timing. This is what we want.

Combo would have some reward (usually better damage, but it could be more loot, or simply more score). I mention this because you can leave the combos be emergent or scripted, however we want to have an incentive to use them.

Addendum: If the combos are emergent, the game needs to be aware of them, or more precisely, of the context of each attack, that is what was the previous attack, how much time ago, to what enemie (was it the same enemy?) and what is the state of the enemy. And then, it can reward you.

Taking a page from the design of Devil May Cry. You can throw enemies into the air, jump to meet them, smash them down, and land on them with another melee. It can be more interesting if you have a way to pull enemies to you.

Taking another page... your raged attack is a verb you can mix. There are two main blueprints for these combos:

• Using a mele attack, throw enemies into the air, then shoot them.
• Mega Man Jump and shoot enemies from the air, and land with melee.

Once you consider these, you will also consider jumping to with them, then pushing them down, and then shooting them from the air, landing with melee, and then repeat.

For ranged attack, it can be useful to be able to (if not have something like bullet time) slow down the fall of a jump. If you lack another input command for something like this, consider the use of holding melee to slow down falling. It will allow you to jump, slow down the fall, aim and shoot. And will also allow a bit more vesatility in platforming.

• I feel like there's a lot of useful info in this answer, but it is not quite clear to me. E.g. you talk a lot about "verbs" vs "commands", but I can't tell from the text where the difference between a "run as a verb" and "a run command" is. Also, what is "run" in this context? I interpreted it as "move" first, but the examples for input methods you give suggest sprinting, maybe? Jun 4 '18 at 12:24
• @RutherRendommeleigh you are right I have been vague on that. Added a definition of verbs, and commands in terms of verbs. And yes, sprinting is appropriate. I will still call it run. Jun 4 '18 at 13:19
• This answer is super-in-depth and provides a lot of useful information. Much of which is completely irrelevant to the asked question. Jun 4 '18 at 17:05
• @Delioth I knew it! Jun 4 '18 at 17:11

Among the things the others mentioned, consider making some enemies very difficult to kill with ranged weapons. The 5th boss (The Hand) in Furi is like this, as are many enemies in various MegaMan games that require you to get around shields and other stuff to use your gun.

Simply having some enemies with difficult-to-bypass shields that can be neutralized much more effectively with melee gives a natural ebb and flow for the game on which weapon type to use.

Also, Reloading can be a big weak point for ranged weapons. If your reload takes several seconds (even with unlimited ammo) you can expect the best players will optimize how to utilize the melee and the shooting collaboratively as to not let themselves be weak during the reload.

• You can make enemies difficult to kill by having terrain that makes guns ineffective- mazy areas makes reaction time tight with running causing the gun naturally bounce and the aim to go astray. Jun 6 '18 at 9:56

LEOs cite the time it takes to react, unholster, unsafe, and aim a firearm, vs the time it takes a knife wielder to close the range. If a the knife wielder is closer than ~7 meters, they can close before you can get your gun out. Also, even FPS should recognize the real-world difficulties in going around w finger on trigger of an unsafed weapon. There must be some reason SWAT teams, HRT, SEAL teams etc., don't do that- there's too much danger of an accidental discharge, losing stealth, and possibly shooting your team members. People stumble, get distracted, etc. Rushing a gunman is risky; rushing a swordsman w main a gauche is suicide. (Nod to Heinlein.)

The answers here are very excellent, but something you could also consider:

• Implement disarming; that is, if you can sneak up/jump on/get to a gunner, you can disarm them as a melee ability which then forces them to use melee. This makes melee mains very helpful when you can get to a gunner without them killing you.
• Implement deflection. Sort of similar to [Overwatch] Genji's E ability (deflect), you can implement a long-cooldown ability that will deflect bullets back at the sender, which allows you to close the distance to a gunner and force them to use melee (since shooting you would just deal themselves damage).
• Implement strong shields. Sort of similar to [Minecraft] regular shields which completely block arrows but not their effects and [Overwatch] Reinhardt, Brigitte, Orisa, and Winston's shields which block all bullets and drain shield HP, you can implement shields which can either regenerate or require repairing, which allow you to hold them out and charge a gunner while blocking the bullets. This is similar to deflection but slightly less overpowered because they can break your shield if you are running at them for too long of a distance / if they are moving back to maintain distance.

A good game to study for this would be the free MMO Warframe, which provides a rich choice of ranged and melee weapons for the player. They make it clear that use of each weapon type is situational; using a rifle to hold off enemies from range and using a sword to cleave through several smaller enemies that are harder to hit. Both weapon types don't have to be equally viable in all situations.

• I would add that the ability to have all 3 weapons (in this case, primary/secondary/melee) all do different types of damage generates an additional reason to use all three.
– user59192
Jun 3 '18 at 9:09

The key difference between a melee weapon and a gun is the range; everything else can be tweaked. One way to look for options to change things around is to simply look at how you're balancing a gun vs a longer ranged gun and work from there.

What keeps a sniper rifle from completely overshadowing everything else in your game? The same thing that can be used to make a machine gun beat a sniper rifle, or a shotgun beat a machine gun can be used to make a sword beat a shotgun.

There's a few key things, like balancing out range with lower rate of fire (a sniper rifle vs a machine gun), lower base damage (a machine gun vs a shotgun) or lower ammo capacity before having to reload.

Ammo capacity especially is easy; melee weapons don't run out of ammo so if the fight lasts long enough that your opponent runs out of bullets you're almost certainly going to win. Even if they need to reload, that might you give all the opening you need. (Doubly so if you can't reload in melee because taking damage aborts your reload action).

Higher damage is also easily added; video-game swords already cleave people in half so nobody will bat an eye at melee weapons dealing a ton of damage.

In 3d games there is also the advantage that it's hard to hit something that's very close because it's moving very quickly compared to your viewpoint. This advantage doesn't exist as much in 2d, but you might introduce a mechanic to simulate it. For example if you take melee damage, your weapon's base damage goes down due to distraction. This would make shooting in melee much harder because once you are hurt, you won't be able to fight effectively. Make the effect more profound the longer ranged your weapon is, and make switching to a melee weapon take some time, and a sniper will start sweating a lot when a melee character moves in close. They'll have to choose between trying to drop them before they are hit, or accept that they're probably going to lose.

A point that has already been mentioned is map design; a sniper rifle is useless if the map is a maze with no clear stretches. But you can also add tools that change the map design in the advantage of melee wielders. A smoke grenade that reduces ranged damage by a large amount can be used to close distance (or protect you from a hail of gunfire while you flee). Likewise, a shock grenade that temporarily disables ranged weapons can give you time to re-position.

There are many good answers here already, but I would like to add a couple of insights.

There is an episode of the Mythbusters tv show where they experiment with bringing a knife to a gunfight. They had the gunner keep his gun in a holster before they started, so it was perhaps a poor comparison, but they found that it was a much closer fight than you'd think. Guns have to be aimed, and that can be difficult when things get hectic.

It's also very difficult to shoot someone who is interfering with your aiming. Controlling your arms, etc.

This might not apply to your game, but making it difficult to aim both precisely and quickly is something that can be implemented in a game.

Secondly, stealth. Guns are loud, and a knife can be very deadly against an unaware opponent. Again not the most applicable to your type of game, I suppose.

Lastly, many games have combined ranged and melee combat already. For inspiration, check out Street Fighter, Alien vs Predator, Halo, Tenchu Stealth Assassins and many more I'm sure. ;)

• I was going to ask about the Touhou x.5 Danmaku fighter games (mostly 13.5 and up), since an important part of the melee is the A-string that can combo into ranged attacks, and in some cases be combo'd into. Maybe I can use that. Jun 6 '18 at 8:29

One more alternative is make melee combat a lot flashier and visually/auditory impressive compared to ranged combat. The visual feedback does not have to match the actual damage, but a melee combat system that looks and feels really powerful can cause people to naturally prefer it over the other option, even if it might be numerically slightly weaker.

• This can have a negative effect on player experience, as described in Water Finds a Crack. When there's a safe, reliable / numerically superior way to play, many players will consciously or unconsciously choose that route, even to the detriment of their own enjoyment of the game (less flashy effects etc). For this reason we usually want to balance our mechanics so that the numeric advantages and the fun / cool factor both pull players in the same direction, into the heart of the game, rather than acting as opposing forces. Jun 5 '18 at 13:29
• When there's a safe, reliable / numerically superior way to play, many players will consciously or unconsciously choose that route, even to the detriment of their own enjoyment of the game (less flashy effects etc). Game Theory, right? Jun 6 '18 at 8:29
• I play a game online where if the outcome of the battle is assured either way, I consciously choose the tactics with FEWER cool special visual effects -- very few animations or special effects are fun the hundredth time you have to sit through them to get back to playing the game.
– arp
Jun 27 '18 at 20:58