Caching Collisions "Caliber"

Hello All,

I’m currently working on a melee combat game (swords, maces…).
To simulate the strikes and detect hit i was thinking about using an old tricks from a previous 2D game i wroted.

<<for each group of strikes i store a hidden geometry that is in fact the move of the sword for a time slice.
When Player “strikes”, i would spawn the hidden geometry and animate it (rotate it in fact,according to player speed) and use this hidden geometry to detect if its sword collide to the other player sword or body>>

I was using it because at the time , i had no built in collision detection in the engine, nor collision library able to detect so fast collisions.

Now i would like some inputs:

  • in P3D, is it better to attach a simple collision model to the sword and rotate directly the sword ? (ie is P3D collision detection fast enough to detect very fast contacts?)

your problem is not the speed of the collision detection, but the manner in which it is implemented. In the example you gave, your problem lies indeed in the fact that the swords (or sword/body) may have crossed each other in between two frames*. Panda has a method to interpolate the positions of the elements between frames. This feature can be enabled by calling

[your collision traverser].setRespectPrevTransform(1)

I must admit that I haven’t used it myself yet, so I don’t know how effective it is with 2 moving elements.

As to the efficiency of both methods, I’d rather pass that one on to someone with a bit more panda experience, with a reminder on setting collision masks

[size=75]*: (this is called ‘Quantum tunneling’, after the concept of particles ending up on the other side of a wall in quantum physics expiriments)
[/size]

Panda’s collision system might not be up to the task of detecting sword-to-sword collisions.

Firstly, Panda doesn’t have polygon-polygon collision tests. So you can’t have a polygon as a “from” object, and this may make your trick of describing the sword arc with a polygon a bit problematic.

Secondly, the respectPrevTransform functionality is implemented only for one particular case: sphere-polygon collision tests. So unless one of your swords is a sphere and the other one is a polygon, it won’t help in this case.

You can have a CollisionSegment as a “from” object and a CollisionPolygon as a “to” object, however. So you could do sword-sword tests by representing one sword with a CollisionSegment (or even a series of segments) and the other one with a polygon or series of polygons, that corresponds to its arc. That may work, and it would be pretty quick. There’s a slight chance of quantum tunnelling, depending on how close together you put your series of CollisionSegments.

David

Hello, this is trully valuable input;
I have to redesign the fighting system then, it maybe a little more complex than expected :slight_smile:.

The idea between representing Sword Arcs by Poygones is to make the size of the polygon dynamic base on frame elapsed to reduce the quantum tunneling effect.
=>If 3 times units (Tick) are elapsed, i make the polygon include the volume occupied during a 3f Tick time.

I’m trying to understand the idea between sword as collision segment.
What i understand is than I can have my acting Sword as collision segment and my passive sword as polygon but not the reverse way.

So i’m thinking about the following configuration ( if there is 3 ticks margin configured)

  • the blade of my acting sword has attached maybe 3 collisions segment (1 current sword middle, 1 at the position “Tick margin” ago, 1 at the next position “tick margin ahead”)
    This collision segment are attached to my blade hilt so they follow the orientation of the sword given by the animation.
  • the blade of my passive sword is attached a “defense polygon 3 tick sized”
  • the body of my defensive guys is enclosed in a sphere and each body part have a tag that is a kind of hitbox name (like “Hitbox”=“Head”)

So if first check if collision occurs between attacker sword collision segment and defenser sword defense polygon.
if yes => manage animation accordingly
if no => check if collision segment from offensive sword collide with defensor sphere
if yes => recover which body part is hurt… but How?

I guess i have to expose each body part (else animation optimizer will remove them ) but how to recover it from the sphere collision Info?
=> possible optimisation, attach ghost hitboxes (very simple capsule or cube ) around body part

But is it possible?
because each sword is both modeled by a collision segment and a collision polygon so i must find a way (bitmask?) to prevent the self detection of a sword, possibily at collision detection
(it’s easy to do it at collision resolution but i waste a collision detection…)

That sounds like a good approach.

It is easy to determine which body part was hit if you assign each body part a different name or a different tag. You can get the NodePath of the detected intersection from the CollisionEntry that is returned as a result of the collision.

David

Oh i begin to see the big picture :slight_smile:.
Only thing i’m not sure is that each sword is modelled both

  • by a set of collision ray (when considered as “active” sword)
  • by a collision polygon (when considered as “passive” sword)

Is it trully ok for panda.
How do i avoid the detection by collision traverser of my own defense polygon by my own collision ray ?
(collision ray are inside my defense polygon usually)

One idea i have is that maybe i can simply create a ghost polygon around my sword and recover that contact point is the sword by using the same tactic that for hitbox => recovery from sphere collision entry?
So no need for real defense polygon for the sword?

Other idea was to make one collision traverser for each sword and does not include this sword defense polygon in this traverser?
(look expensive)…

Have you assigned different bitmasks for the player sword and the enemies sword ?
If you assign e.g :

  • bit 0 to your sword ray and all enemies’ sword polygon,
  • bit 1 to all enemies’ sword ray and your sword polygon,
    the rays will never collide with it’s own polygons.
    Is that it ?

That was so nice idea sir, about this game its good to heard by you about the new tricks of the swords,
and if you make this one i was interested to play this game again.