I want to get a projectile to return the surface tag but it returns untagged.

Basically i want my projectile to mark the map if its tagged as LevelParts but the problem is that the projectile isnt even detecting the tags on the level. A raycast version works perfectly but this one does not.

The code is obviously detecting collisions but not correctly. What have i done wrong?

	function OnCollisionEnter(collision : Collision) 
	{ 
		for(var contact : ContactPoint in collision.contacts)
		{
	 	Debug.Log("This colliders tag is named: " + collision.contacts[0].thisCollider.transform.tag);
		}
	}

I have tried even changing “ollision.contacts[0].thisCollider.transform.tag” to “contact.thisCollider.tag” and other things.

If its any more help this is the actual piece of code i am actualy wanting this to work on.

	function OnCollisionEnter (collision : Collision)
	{
		for (var contact : ContactPoint in collision.contacts)
		{
			if(decalHitWall && contact.thisCollider.tag == "LevelParts")
			{
				Instantiate(decalHitWall, contact.point + (contact.normal * floatInFrontOfWall), Quaternion.LookRotation(contact.normal));
				Destroy(gameObject);
			}		
		}
	}

function OnCollisionEnter (collision : Collision)
{
for (var contact : ContactPoint in collision.contacts)
{
if (decalHitWall && contact.otherCollider.tag == “LevelParts”)
{
Debug.Log("Tag = " + contact.otherCollider.tag);
}
}
}

This was what i was looking for.

THANKS ROBERT your input heped me by mentioning otherCollider.

If their is only one GameObject interacting w/ these contact points, you can add them all to a seperate layer, and use Physics.OverlapSphere to detect them all first. then you can check for the tag afterwards. guaranteed it will work.

Collider[] parts;
    
parts = Physics.OverlapSphere(this.transform.position, 4); //you can change the parameters if you're using layers.
    
foreach (Collider part in parts)
{
if(part.gameObject.tag == "levelParts")
{
//do stuff
}
}

of course if you do this, you will have to activate it upon collission, or on trigger.

Try:

function OnCollisionEnter(collision : Collision) 
{ 
   for(var contact : ContactPoint in collision.contacts)
   {
       Debug.Log("The other collider's tag is named: " + contact.otherCollider.tag);
   }
}