Collisions with an animated character

Hello there,

I apologize if this is a common question. I tried my best to search through existing questions for a good amount of time but couldn’t find anything relevant.

I’m working on a 2.5D Castlevania style game. I’ve been trying to figure out the best way to implement attacks for the character and enemies without physically moving them forward to force a collision. They are mostly punch/kick animations with a limited number of attacks with melee weapons. The player character and enemies both use Character Controller components.

The only idea I’ve come up with so far is attaching colliders to the hand and foot joints of the models so that when they plays their animations, the colliders are driven forward through them, but this would require a separate script for a GameObject attached to the hands/feet correct (I’m working in C#)? Is this a sensible solution to this game mechanic? Is it possible to have a mesh collider that moves along with animations? I’ve tried to do this, but the meshes all seem to be stuck in the T-pose.

I ask because I followed the Lerpz 2D tutorial’s system for handling footsteps sounds and particles, and I thought it was great while setting up my intro stage but it’s becoming rather tedious to have to add in the scripts for every surface, even while using prefabs because the levels I’m designing after that are rather large and have a lot of unique surfaces.

Thanks for reading and I hope someone can suggest a more efficient method.

Well, I am doing a simple 2.5d game too. In my game I use something like:

  1. Create a empty object;
  2. Attach in this object a script with
    only a Gizmos function;
  3. Put a collider in this object;
  4. Attach the empty object in some
    enemy;

So the empty object works like a “hurting area”, my character just need to have a “if” inside the collider detection.

function OnTriggerEnter (other : Collider)
{
...
	var enemyDamageDetector : EnemyDamageDetector = other.gameObject.GetComponent( EnemyDamageDetector );
	if( enemyDamageDetector )
	{
		SendMessage ( "DidHit", SendMessageOptions.DontRequireReceiver );
		return;
	}
}

This way, it is just put the script where I want. You don’t need to make the script more, only reuse it. I think that you can jump the step 1 and put the script in the joint of the knuckles of your character or wharever.