Game Development Community

Implement attack by throwing a punch

by gamer · in Torque Game Engine · 10/17/2006 (12:52 pm) · 8 replies

I want to have the ai guy punch the player and results in a damage. what's the best way of implement this? As far as I know the collision detection is done by bounding boxes, right? will it detect the extending of the arm and fist from the ai guy's attack animation?
so if the ai guy is in attack mode and he collides with the player from the front, then the player results in an injury. is there more accurate way of implementing the punch attack?

thanks!

#1
10/17/2006 (1:01 pm)
Malee combat is what you want too look up I Think!
#2
10/17/2006 (1:14 pm)
I was mucking around with something like this one day.

I'd already implemented the Server-Side Melee resource, so I created a "brass knuckles" weapon that was essentially a very small 'sword' (as the melee resource saw it). This let me use the already working melee hit detection routines that were designed for swords. The only problem was that the existing animations that have been designed for use with the melee resource didn't work well with the much smaller, basically bladeless 'brass knuckles'. I'd want to find a way to use more appropriate animations for it to work properly. Otherwise, I think it would be one of the easier ways to implement something like this.

Just a direction you might think about, anyway.
#3
10/17/2006 (4:29 pm)
Have the hand joint of a player detect collisions with the collision mesh of other shapes.
#4
10/17/2006 (8:08 pm)
Thanks guys.
I am trying to use teh Server side Melee resource http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5377
I am getting some problems. Bryan did you implement this on an AIPlayer? if so can I see your source for AiPlayer.cs?
I am getting some crasheds when onFireHandToHand is called.
function WeaponImage::onFireHandToHand(%this, %obj, %slot){
if (!%obj.setArmThreadPlayOnce(%attack.seqName)) {//crash!!!!
echo("ERROR in setArmThreadPlayOnce()");
}
the crash is undeterministic becasue I tried to trace it:
bool Player::setArmThreadPlayOnce(const char* sequence)
{
Con::printf("in SetArmThreadPlayOnce!!!!");
// if we are already playing arm thread...ignore
if (mArmThreadPlayOnce){
Con::printf("returned because mAmrThreadPlayOnce is false");
return true;
}
Con::printf("before save old sequence!!");
..
}
in SetArmThreadPlayOnce!!!! is printed out to the console but then nothing else....
has anyone had this happening? if I commented out these two lines. then the aiPlayer attacks like crazy because it plays it constantly not just once.
#5
10/18/2006 (10:06 pm)
How do I have the hand joint of a player detect collisions with the collision mesh of other shapes?
thanks
#6
10/19/2006 (11:11 am)
A simple hack is to use an invisible 'weapon' that fires a very slow, short lived, and invisible projectile, then use existing projectile handlers for damage. Invisible models can be created by only having a collision mesh in the model.
#7
10/19/2006 (3:04 pm)
@gamer No, I don't think I ever did try to have an AIPlayer use it. Once I realized I'd need to create new 'punch' animations in order for it to be effective, I put it aside until I got around to doing that.

I'll try to see if I can provoke a crash doing that, though.
#8
10/20/2006 (2:08 am)
.