Hello!
So, when my player collides with the item (coins) it deletes all instances of the coins in the scene. The coin is a tilemap and I’ve just attached a tilemap collider 2D and a script to the inspector of the coin tilemap with the Is Trigger box checked.
I just want one coin to be deleted at a time when the player collides with it instead of all coins at the same time, but I have no idea how to go about doing so…
Here is the coin script I have attached to the tilemap:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Coin : MonoBehaviour
{
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.gameObject.tag == "Player")
{
CoinCounter.coinAmt += 1;
Destroy(gameObject);
}
}
}