Remove item on collision

I’m new to Unity3D, infact this is my first ever project on it.

I’m trying to do something i think is quite basic.

I am having numerous different objects placed around for a first person camera to ‘collect’ and once collected gets removed from the screen.

However right now nothing is happening.

var itemCount: int;
function Start () {

}

function Update () {

}

function onTriggerEnter(collisionInfo: Collider)
{
Destroy(collisionInfo.gameObject);
}

I have assigned the code to the first person controller, but have also tried it with the object.

Any help would be brilliant

1 Answer

1

Function names are case sensitive if I remember right. You need to change your trigger handling function to correctly override OnTriggerEnter(). Try this:

// change this line...

function onTriggerEnter(collisionInfo: Collider)

// ...to this...

function OnTriggerEnter(collisionInfo: Collider)

changed that, but still nothing

–

Are the objects that you're walking into have Colliders on them with the "Is Trigger" checkbox checked?

–