In my game, I have Diamond objects tagged as “Diamond.” I have the following C# script attached to my Player object (tagged Player). However in game, the Player just pushes the Diamonds around when it touches them. I have a Rigidbody2D and a Box Collider 2D on the Diamonds. What can I do to make the Diamonds disappear? Thanks.
using UnityEngine;
using System.Collections;
public class Diamonds : MonoBehaviour
{
void OnTriggerEnter2D(Collider2D collider)
{
if (collider.gameObject.tag == "Diamond")
{
Destroy (collider.gameObject);
}
}
}