Melee Weapons and Collision

For questions about using Classic.

Post » Tue Feb 23, 2010 11:34 pm

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.
B
2
S
2
G
2
Posts: 372
Reputation: 1,794

Post » Tue Feb 23, 2010 11:43 pm

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.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Feb 23, 2010 11:47 pm

I'm sure Castlevania was a lot of work ;)
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Wed Feb 24, 2010 12:08 am

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.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Wed Feb 24, 2010 1:39 am

[quote="deadeye":3jj693fv]Edit: Deleted your duplicate thread.[/quote:3jj693fv]
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?
B
2
S
2
G
2
Posts: 372
Reputation: 1,794

Post » Wed Feb 24, 2010 1:51 am

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



Leave it there for the duration of the sword swing animation and check collision against that.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Feb 24, 2010 1:57 am

[quote="deadeye":148oh916]If you're swinging a sword in an arc, how about you make a pie-shaped detector like so:



Leave it there for the duration of the sword swing animation and check collision against that.[/quote:148oh916]
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.
B
2
S
2
G
2
Posts: 372
Reputation: 1,794

Post » Thu Feb 25, 2010 10:53 am

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.
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Thu Feb 25, 2010 5:19 pm

I think I said in the now deleted duplicate thread about using separate hitboxes. So yeah, seems to be the best/easiest way.
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Sat Feb 27, 2010 2:22 pm

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.
B
2
S
2
G
2
Posts: 372
Reputation: 1,794

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests