I am making a game were the ball is the player and i need to know how to destroy the player when it collides with the wall game object. is there a way to do it.
Look at the OnCollisionEnter() docs.
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnCollisionEnter.html
after reading the docs add this script to your wall objects.
function OnCollisionEnter(Collision collision)
{
if( collision.gameObject.tag == "Player" )
{
Destroy(collision.gameObject);
}
}
(@iggy and Antony Blackett) shall i put this script in the player or the wall:
function OnCollisionEnter(collision:Collision) { if( collision.gameObject.tag == “Player” ) { Destroy(collision.gameObject); } }