How to detect a player attack

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
prchakal
Posts: 58
Joined: Thu Sep 24, 2009 12:31 am

How to detect a player attack

Post by prchakal »

Hi,

What the best method to detect the player(node/mesh) attack ?

Im using md2 models.

What the logic used to detect when the player attack other ?

Can anyone help me?
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

Not totally sure what you're getting at here. Usually you're the one with the variable of whether or not they're attacking. Or are you trying to determine if they hit something?
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Post by 3DModelerMan »

I used the bounding box of my characters sword, and checked it against the bounding box of the enemy object. You could make the weapon bounding box bigger and check if the enemy position is in the box as an alternative. But if you're checking for bullet hits I havn't gotten to projectiles yet so I wouldn't know.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

You could also cast a ray of a certain distance forward from the player and see if it intersects the enemies bounding box.
prchakal
Posts: 58
Joined: Thu Sep 24, 2009 12:31 am

Post by prchakal »

Yeah, i think it, check the bounding box of sword, but the sword is built with the player model (md2), can i take only the sword?

How you do to attach wepaons at the model hand? What the technics is used?

Can you explain to me how to attach the sword or weapon and get a bounding box of this sword/weapon in md2?
Daniel FF
Posts: 53
Joined: Tue Feb 19, 2008 7:15 pm

Post by Daniel FF »

Hi,
you could keep character and sward separated, just using same pivot at models and synchronized animation frames.

But, why not just test the distance between nodes? I think you dont need collision in this case, if an node atack and distance from another node is < 18 (for example) you got a hit.

Sorry for my bad engilsh!
Murloc992
Posts: 272
Joined: Mon Apr 13, 2009 2:45 pm
Location: Utena,Lithuania

Post by Murloc992 »

prchakal wrote:Yeah, i think it, check the bounding box of sword, but the sword is built with the player model (md2), can i take only the sword?

How you do to attach wepaons at the model hand? What the technics is used?

Can you explain to me how to attach the sword or weapon and get a bounding box of this sword/weapon in md2?
Well You need to attach the sword to character's palm joint and make it sword's parent, so it can share rotation and location. Then you can check sword collision with other character :)
prchakal
Posts: 58
Joined: Thu Sep 24, 2009 12:31 am

Post by prchakal »

@Daniel FF
The problem is not to check is to determine when the player is in attack mode, i think that i can by the frame number, but it a poor implementation, so i prefer the colision with sword.

@Murloc992
Humm ok.

You have a joint tutorial or demo that i can check how to do it with player and weapon?
Post Reply