So I have two, let’s say, diamonds in a level of my game. And if the player hits an obstacle, the level reloads with scenemanager.loadscene. But the thing is I want to use a UI text to show amount of diamonds and I used a playerprefs to store the value. But apparently the counter only increments for the seperate two diamonds meaning if I take a diamond, hit a wall and take the same diamond, it won’t increase the diamond counter. How can I fix this? Here is my script. Thanks in advance.
void OnTriggerEnter(Collider info)
{
if (info.CompareTag("Diamond"))
{
diamondCount++;
diamondText.text = diamondCount.ToString();
PlayerPrefs.SetInt("Diamonds", diamondCount);
Destroy(info.gameObject);
}
}