Hello to everyone . I have made 2d games these days. Butttt I have a lot of mistakes or error I do not know
The error is that
There are 5 diamonds in my map. Each diamond is a polygon collider. When the character touches the diamond, the diamond value increases 1 -----------> NORMAL
, but sometimes when the character touches any diamond, diamond value increases 2
I don’t want that -----------> ERROR
My script is that
private void OnTriggerEnter2D(Collider2D diamondCheck)
{
if (diamondCheck.gameObject.tag == "diamond")
{
Destroy(diamondCheck.gameObject);
GetComponent<AudioSource>().PlayOneShot(coin);
diamondValue= diamondValue+1;
}
Where is error I don’t know please help me