OnCollisionEnter

Hello Unity3D.I have a question about OnCollisionEnter?If i want OnCollisionEnter to work at it’s best should i add an empty gameobject to the area that i want it to contact the enemy with and add a rigidbody and capsule ?or should i just add it to the armature of the character and add a rigidbody to one of its limb instead?The reason why i ask this questions is the fact that i have seen onCollisionEnter work best when it comes to projectiles instead with close combat(such as swords or fist).If anyone knows which way is best.Can you please tell me why?

Try adding a empty parent object and see how it works out. Once you figure out the collision bugs and work them out, then add them to your limbs. If you are swinging a sword and you want the enemy to play an animation on hit, try using OnTriggerEnter instead of OnCollision. Ontrigger can still pass over damage amounts and alot more.

void  OnTriggerEnter ( Collider other  )
	{
		if(other.gameObject.tag ==  "Dummy")
		{
			other.transform.gameObject.animation.Play ("Hit_Stomach"); //I think this is the right wording
		}
	}

Is all you need. No declaring variables needed. This will be attached to your “sword/fist” and will make the other gameobject play it’s animation.

You can also turn on the collider at the beginning of the animation and turn it off at the end so you wont be dealing damage or/or animations to other objects while not swinging.

Hope this helped and what you are after.

James