how to get the nme of the object that the character colide..

I am new to this and I am trying to get the name of the object that my character colide with. how do I do that? DO I assign the script to my first person camera or to all other objects around the character?

Thakn you in advance

You can use an OnCollision or OnTrigger type function… These either pass back a collision object or a collider object.

Here is some links for the documenation:

http://unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnCollisionEnter.html

http://unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnTriggerEnter.html

Hopefully these will help provide some information.

Regards,

– Clint

Itry the OnCollision but is not doing anythig. Do I attache the script to the First person controller? Do I n eed to set any other property?
what I am trying to do is to identify the ladder objet so I can go up the ladder. I dont know how I am going to go up the ladder yet but One step at a time. Fisrt I need to know when I get to the ladder. any suggestions otu there.

Thank you,

i usually attach the script to the object doing the colliding. So…

function OnCollisionEnter(collision : Collision) {
   	
    Debug.Log (collision.collider.name);

}

Haven’t tested, but create a new blank script and paste this into it and attach to your GO doing the colliding.

cheers.

Hiya,

Both objects that you are looking to get collide infromation from need to have either a collider or rigidbody attached to them. Then the script could be attached to either… I would most likely attach it to the object you are controlling versus the other objects in the scene.

HTH,

– Clint

I am using a fisrt person shooter prefab. DO I attached to script to the prefab or to the actual character objet insode the prefab