Melee Weapons in a 2D Top Down Shooter

Started by
5 comments, last by Sean_Seanston 12 years, 9 months ago
In my Top Down Shooter, I've implemented projectile weapons that spawn projectiles which then carry on and collide with things etc. but now I've come to implementing melee weapons and I'm torn about how to proceed.

Should I have some kind of collision box defined and after beginning an attack, a timer is started and when that timer reaches a certain point, anything in that area is considered hit by the weapon?

What would be a usual way of going about something like this?
Advertisement
The method you suggest sounds reasonable to me; there may be cleaner options, but it's hard to say without knowing more about how your engine is structured.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

There are a few techniques which might be appropriate depending on how you want the weapon to behave:

  • When you attack, damage any enemies within a certain distance
  • Define a damage area (could be a point, an arbitrary polygon or an arc in front of the player, for example) and damage any enemies within this area
  • Attach additional information to the animation data - different damage areas could be associated with each frame of the attack animation
If you have projectile objects, why not make the melee attack a projectile as well? Just one, large, static projectile in front of the player that has a set fade-time.

If you have projectile objects, why not make the melee attack a projectile as well? Just one, large, static projectile in front of the player that has a set fade-time.


Yeah, that had crossed my mind. I suppose in real terms though, using the Projectile class here would just be making it slightly easier to implement collision areas like I was saying so it still leaves that question.

A slightly more complicated idea I had was just a collision box like I said, but instead of 1 there's any number in a list and they could also have separate activation and deactivation times if desired to model some kind of gradual sweeping motion. Either way, it could be used with 1 collision box and be more or less the same as my initial idea.

Sound alright? It's amazing how complicated the seemingly simplest of things get once you start actually implementing them :rolleyes:
You don't need to have multiple boxes. You can have one box and then rotate/move that box over time, noting any collisions that happened.

You don't need to have multiple boxes. You can have one box and then rotate/move that box over time, noting any collisions that happened.


Oh yeah, I didn't think of that... that's a bit simpler.

I'll see how it goes anyway.

This topic is closed to new replies.

Advertisement