How to make object disappear when placed in another object?

I’m new in Unity and I’m sorry this question it’s just like order you guys to make a script for me. I’m terribly sorry but I really need it.

let’s say I have trash bin object in my game and whenever I put another object like sphere maybe, that sphere will disappear. It doesn’t care how many sphere will be put in that trash bin. As long as the trash bin isn’t full the trash bin will make another object inside it disappear.
How to do that? Please help me :slight_smile:

To remove a object from the game you can use the Destroy function described here.

And to check if the object hits something you can use the OnCollision functionality described here:

So by combining these two you can check if the object you throw in the trash bin hits the trash bin and then destroy that object from the game:

Example code:

    void OnCollisionEnter(Collision col) {
        if(col.gameObject.name == "TrashBin")
        {
            Destroy(col.gameObject);
        }
    }

Okay! Thanks for the responses!I’ll try then.