Damage effects

I finally got around to working on some better damage effects.  All I had before was entire characters flashing red when hit.  It was functional but not very fun and didn’t give you any information about where you hit the enemy.

I knew I wanted some very accurate blood spray – it should come from the first spot that your blade intersects the enemy, and spray in the direction of the blade.  The problem is that the sword moves very fast, even with 60fps frames it will tend to skip right through an enemy body.

My first attempt was to use Box2D’s Continuous Collision detection to solve this.  I setup several physics bodies on the character and several on the weapon and told them to listen for contacts with each other.  I never figured out why, but they would not consistently collide, even when enabling CCD.  I have a feeling it’s because one of the sets of bodies were sensors only – which means Box2D only notifies them of contacts but doesn’t actually collide them.

My next try was to use the same simple method I use for sword trails: subdivide the animation as long as the distance between weapon points are too far.  This works great for weapon trails and ensures that they are smooth, no matter what the framerate is, or how fast the weapon is moving.  For hit effects it’s similar, I just have to check whether the weapon is intersecting the enemy body at many times within the last timestep.  I setup a convex hull on each bone of the enemy that can be hit, since that’s a really efficient yet accurate representation for intersecting points.

Collision

Now that I knew where the weapon hits, I needed to make a particle effect to represent the blood spray.  Vanilla red particles don’t really cut it, blood has a very unique look.  I combined a few basic techniques to make it look better – stretching the particles along the direction of movement, and accumulating blood density instead of blood color.  Once I accumulate density it’s just a matter of applying a lookup texture indexed by density that gives the final color of the blood.  These two things are really effective at making a blobby, dynamic fluid effect.

Blood2

Now that I have it working, it’s amazing how much more satisfying basic attacks are, especially with the sound effects.  I’m not completely happy with it though, the effect is not at its potential.  I would like to keep around some parts of the blood that spray on the environment.  I would also like to have some dripping off of your weapon for a while.

Leave a Reply

Your email address will not be published. Required fields are marked *