can you have a Tag inside a tag and check for collision with that?

currently i have a Player (moves and stuff) (tagged Player)within the Player i have a sword which (tagged sword). i want to check if a cube hits the sword. how would i go about this?

i have tried using triggers and normal collision (have used rigidbody, box, spehere,mesh...collders)

this script is attached to a cube

function OnCollisionEnter(hit : Collision) {

if (hit.gameObject.tag=="sword"){ print ("hit"); }}

You didn't say what exactly is happening, but odds are you are having the common problem of not getting notified of any collisions. If you search Answers for OnCollision and OnTrigger you can see how other people have fixed it. Make sure both objects have colliders; one of them needs a Rigidbody on it as well.

It's possible that OnCollisionEnter IS getting called, in which case the problem may be with your If statement. Make sure you spelled and capitalized the tag name correctly in your code. Aldwoni's suggestion can help you see if that's happening: add his Debug.Log command to the first line of your OnCollisionEnter method, or use breakpoints (if you are debugging with MonoDevelop.)

if you want a tag inside a tag you can use the inside string to determine your inner tag example

your object tag could be "ArmSword"

hit.gameObject.tag.contains("Sword")

the contains will see that your tag have Sword in it so it will be detected as sword, but if you use

hit.gameObject.tag.contains("Arm")

then it will be considered as Arm

is just a vague example but is the easiest way to use your tag inside a tag