This is a duplicate question, however you would go attach a script to your character and add the following function:
// in js:
function OnCollisionEnter (other : Collision)
{
Debug.Log("I collided!");
if (other.gameObject.name == "Wall") {
Debug.Log("Collided with wall!");
}
}
// in c#:
void OnCollisionEnter (Collision other)
{
Debug.Log("I collided!");
if (other.gameObject.name == "Wall") {
Debug.Log("Collided with wall!");
}
}
if you need the information every frame use:
// in C#:
void OnCollisionStay (Collision other)
{
Debug.Log("I'm colliding!");
if (other.gameObject.name == "Wall") {
Debug.Log("Colliding with wall!");
}
}
hope it helps