Action melee combat

How to make melle blows like in action games using bullet?

Can you be a bit more elaborate, so I understand what you want to know?

Suppose there is an actor holding a sword.I need to move this sword to execute a blow to check the collisions if it hit the target.How to make it move or is it another way?Like the bullet object moving with the geometry object when its animate?

Ok. I should mention that I am not that much of a game developer that I know best practice pattern for all such problems. So please take into account that I might tell you nonsense.

What you could try is to expose the joint which represent e. g. the sword or hand of your player character (see Panda3D Manual: Attaching an Object to a Joint), and then reparent the sword rigid body to this joint. If you set the sword rigid body to “kineamtic” then the rigid body should move with the joint.

But I am not sure if this is the right way to go, because now you run into problems if the sword hits an enemy. Enemies (or other obstacles) will be pushed out of the way, no matter how heavy they are. Also it might pass through static objects. This might not look very realistic. On the other hand you could maybe work with collision mask…

I would consider a more minimalistic approach. Like having no physical object for the sword, and just do a ray test (or sweep test) once at some time of the attack animation. The problem ist to compute the best start & end points for the ray.

First consider how accurate collision detection needs to be, and go with the crudest option that will work for your gameplay.

The cheapest way is just a distance check. If you’re within range of target, you hit. You can also modify that with, for example, a stats roll, if it’s that kind of game.

Or, if you want to be more accurate, put a collision solid around the sword and collision solids around the body parts, use an event collision handler to check for hits. I wouldn’t use a full-on physics library for that unless there’s a specific reason you need it.

Somewhere in-between, I think, might be the use of animated arcs: a weapon-blow is defined by a range, a swing speed (the number of degrees/radians per second at which the weapon is swung), a current angle (representing its position in the swing as of the end of the current update) and a last angle (which is simply the “current angle” from the last update). A hit is then scored in a given update if the target is in range, and the angle to the target lies between the current angle and the last (inclusive of both).

(While of limited use for short swings, this system might prove useful if larger swings or spinning attacks are called for. With the addition of updating the range you could extend it to simple ranged attacks, such as a wave of fire sweeping outwards or a spiralling missile, if I’m not much mistaken.)