Game Development Community

Collision for melee attack

by rwillis · in Torque X 2D · 12/12/2008 (7:56 am) · 3 replies

For setting up the collision for a melee attack, would it be alright to create an animation of the melee attack and then change the collision image every frame (using InstallImage()) to adjust to the new position of the object (i.e sword)? Or would it be too slow?

Obviously, the other way may be to just create a sword static sprite and then move it using the physics system (i.e. setting angular velocity, rotation, etc) and having the collision come from that.

How is everyone else handling this?

#1
12/12/2008 (12:32 pm)
It seems you are referring to 2D, and I'm actually talking about my experiences in 3D with another engine altogether, but I think the idea still holds true...

I have found that with melee combat, there's not any strong need to actually detect collision of the melee weapons themselves. What I do instead is have an animation trigger that's set at a point in the animation timeline where the weapon *would* hit if there were an opponent within range, such as at the far extension of a sword strike, and when that trigger fires, I use a sensor sweep (in the other engine, a sensor sweep is a range-based detection of enemies within the hemisphere in front of the character) to detect if an enemy combatant is in fact 'in range', and if so I just consider that a hit.

The details aren't really as important as the idea that even a very simple but well-timed check for an enemy in range of a given attack is sufficient to look realistic and still have good and fun gameplay.
#2
12/12/2008 (2:02 pm)
Yeah, I may find that it only requires a simple collision check (maybe one) so I may only need one collision image for the animation of the swing. I'll post back how changing the collision of the animation each frame worked out, just for the hell of it. It sounds like a sensor sweep, as you talk about, may be similar to the FindObjects method that's in the T2DSceneGraph class although not sure if FindObjects could do that.

Thanks!
#3
12/13/2008 (5:41 pm)
I definitely recommend at least trying it. If you find out that it works well enough for your purposes, you'll be glad you didn't do something much more complex :)