3rd person fighting

I got a man with a club. Another men attack me and I want panda detect when i hit’em with the club (yeah exactly when he makes the hit animation). I’m asking about a good (but so precisly) collision detection for my game

well the only way to do collision detection is by using collision detection (you already guessed that much).

basically you have 2 choices. either use panda’s buildin collision traverser. or you hook into the one from ode using events.

in both cases you would attach collision solids to the joints of your model.

unless you plan to do physical interaction you propably are a lot better off by simply checking orientation and distance to your target.
“real” collision detection for hits is not neccessary in most cases (unless you have close-up slow-motion shots of the process). avoiding collision detection and checking for orientation and distance usualy is a lot faster, and more robust.

I dont know how realistic your game is, but you could go with a single collision sphere for the player and enemy, and check if they are intersected when the attack button is pressed to make the damage.

You could use ‘hit boxes’ like Thomas suggested. Not really boxes, but lowpoly shapes similar to the body part in shape and attached to the bone of that body part. I would use this myself if I were to make a 3d fighting game, first person shoother or any game where it is important to know which part of the body was hit. If it isnt, then the 1st option is easier to me.

So, i could use a poiting system to detect if the foe is front of me, the i calculate how near is he from me.Any way all foe runs pointing at me. It’s ok if I draw a thin and small laser beam to detect if I am pointing to something. Sorry if you doesn’t underestand me. I a cuban game programmer and it’s a bit difficult to me explain this in perfect english. I want to make a “legend of zelda(ocarina)” fighting style like a hack’n slash

you could have collision spheres attached to player and enemy. If attack button is pressed, check if the spheres are colliding, if they are colliding, then enemy was hit. You could use an additional ‘laser’ (collision ray) to make sure that the player is also facing the enemy.

this is good for leaning panda collisions:
[Panda3d Collisions made simple)

First detect if the club is colliding with him, then use an if statement to check if the club is being swung. If so, then you’ve detected a hit.

to clear things up a little. if you dont need physical accurate collisions, you wont need collisions at all.

the following script would be enough to check if you (the attacker) looks at the target, within a specified angle and distance. and returns true if you’d hit.

fast and easy unless you have HORDES of enemies. you would need to check once for each enemy. which is no problem as long as your enemy count remains sane.

from direct.task import Task
import direct.directbase.DirectStart
from pandac.PandaModules import Vec3


box1 = loader.loadModel("box")
dummynode = render.attachNewNode("dummy")
box2 = loader.loadModel("box")


box1.reparentTo(render)
box2.reparentTo(dummynode)

box2.setScale(1.5,1.5,1.5)
box2.setPos(3,0,0)

def testHit(node1,node2,threshold=15, dist = 1):  #node1 which looks for a target , node2 is the target , threshold is the max-attack-angle, dist the dist
  dummynode.setH(dummynode.getH()+1)
  dirVec = node1.getRelativePoint(node2,Vec3(0,0,0))
  dirVec = Vec3(dirVec[0],dirVec[1],dirVec[2])
  
  dirVec.normalize()
  angle = dirVec.angleDeg(Vec3(1,0,0))
  if angle < threshold and dist > node1.getDistance(node2):
    print "hit at "+str(angle)+" degree!"
    return True
  else:
    print angle,node1.getDistance(node2)
    return False

def testTask(task):
  testHit(box1,box2)
  return Task.cont

  
taskMgr.add(testTask,"testtask")
run()