Melee Weapons and Collision

This forum is currently in read-only mode.
  • I've been wondering lately how to do melee weapons. In Castlevania, the weapon (during the attack animation) has its own hitbox. I'm sure I can't have two collision masks on one sprite at the same time, so do I have to make a seperate weapon sprite? That sounds like a lot of extra work to make them look/work like one sprite and all that. Any help is appreciated.

  • You could add image points to your sprite. Depending on how big it is, you could get away with just checking for collision against the point. Or you could position a weapon-shaped sprite on the point and use that as your collision detector.

    Edit: Deleted your duplicate thread.

  • I'm sure Castlevania was a lot of work

  • Not sure what the question is.

    Any way there is an inherent problem with collision checking for a melee set up. The problem is that since your using v-sync there is a chance that a collision may not be detected. This could be a real issue since your close to the target. One way to deal with this is to not use collision detection at all. Instead you can compare the distance between them, and trigger an animation that is the attack.

    The thing is, is that since your right next to the object your pretty much guaranteed to hit it, and then if you want the chance of a miss just check and see if a random percentage is true. If the comparison to a random number is true then set it to do damage to the object.

  • Edit: Deleted your duplicate thread.

    Oh, thanks. I clicked submit then it said I had to sign in, so I thought it didn't post the topic (it went straight to the "Create a Topic" thing again).

    So it looks like I have a few options:

    1) Use an image point. Good for simple, small sprites.

    2) Create a second sprite for the weapon.

    3) The animation is just for show, but distance determines if it hits.

    I'm liking number 2 the most as it seems like it would have the most "correct" collision (hitting when the weapon actually hits), but I don't know how vsync affects things. Would "Is Overlapping" solve vsync problems as it would be overlapping for a longer time than just a single collision detection?

    Edit: What if each frame of the animation is held twice? That would give it a better chance to register right?

    Edit 2: Would setting a fixed framerate help with the vsync thing?

  • If you're swinging a sword in an arc, how about you make a pie-shaped detector like so:

    <img src="http://i46.tinypic.com/hvrxmv.png">

    Leave it there for the duration of the sword swing animation and check collision against that.

  • If you're swinging a sword in an arc, how about you make a pie-shaped detector like so:

    <img src="http://i46.tinypic.com/hvrxmv.png">

    Leave it there for the duration of the sword swing animation and check collision against that.

    Hmm, that looks like it would work.

    Edit: Also, any "Hit before the sword reached enemy" type problems would be solved by making the animation fast (kind of a given) but also delaying seeing the results of the hit until after the animation is finished. It'd be like in an anime where some guy slashes an enemy and then a few seconds later (much shorter in this case) you see him get cut in half.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Actually, funny thing, the weapons in Castlevania don't just simply have their own hitbox. They're entirely different seperate sprites to the character him/herself. In other words, they use method number 2. I use this method myself, and I find it's generally very reliable.

    And, on the plus side, you can simply re-use animations for certain weapons. Take Castlevania: Dawn of Sorrow, for instance. Soma has attacking animations for particular types of weapons, no animations for specific weapons, the only exceptions being the pistol and the RPG launcher. Soma's animation for lighter weapons such as a knife or a short sword, for instance, is a quick one-handed forward strike. His animation for heavy weapons is a two-handed overhead swing. And one of the neat things about these re-used animations, is, that the animation speed varies depending on the weapon's weight, if I remember correctly. "Lighter" heavy weapons he will swing quicker than heavier ones.

    But, yeah, I reccomend using separate sprites for the weapons, it's a common technique, and it's practically the best one for dealing with many weapons.

  • I think I said in the now deleted duplicate thread about using separate hitboxes. So yeah, seems to be the best/easiest way.

  • Actually, I just beat Dawn of Sorrow yesterday. I've been studying how they do things so I went to look at a sprite sheet to see how they do their animations and noticed the seperate sprites and all everything. That's to be expected since it would save a lot of resources (weapon sprite vs player and weapon sprite) and be much easier to deal with.

  • Actually, I just beat Dawn of Sorrow yesterday. I've been studying how they do things so I went to look at a sprite sheet to see how they do their animations and noticed the seperate sprites and all everything. That's to be expected since it would save a lot of resources (weapon sprite vs player and weapon sprite) and be much easier to deal with.

    That's what I said, and it keeps things neatly in nicely optimized pow2 sizes.

  • I've been wondering lately how to do melee weapons. In Castlevania, the weapon (during the attack animation) has its own hitbox. I'm sure I can't have two collision masks on one sprite at the same time, so do I have to make a seperate weapon sprite? That sounds like a lot of extra work to make them look/work like one sprite and all that. Any help is appreciated.

    I am interested to know also about melee weapons and how will use to attack the enemy.

  • I know two ways: attach invisible sprite with weapon swinging shape collision or use invisible bullet with short range and high speed

  • Thank you for that information.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)