I tried the Debug.Log he doesn’t seem to recognise the collision at all … When I try to use gameObject.Destroy() he says I have to fill in something between tghe brackets but use gameObject.Destroy(gameObject) nothing happens T_T
Have a function on the target you want to destroy where it will kill itself like:
function Die()
{
// Do whatever you need to do
Destroy(gameObject); // this should destroy the game object this script is attached to
}
then on your trigger instead of calling the destroy call use something like this:
function OnControllerColliderHit(hit : ControllerColliderHit)
{
if (hit.gameObject.tag == "death")
{
// this will send a message to the collided object to call it's die function.... if it doesn't have one the call is ignored
hit.collider.SendMessageUpwards("Die", SendMessageOptions.DontRequireReceiver);
}
}