I am making a game, similar to the one in this tutorial: https://www.youtube.com/watch?v=r5NWZoTSjWs&list=PLPV2KyIb3jR53Jce9hP7G5xC4O9AgnOuL&index=11
I am trying to implement collectable "objects" that give you more points (3 of them on one level) So I used a variable gemCounter, that increases by one every time the player collides with the "gem"
What's wrong? On every trigger, the code returns 1 as the result...
using UnityEngine;
using UnityEngine.UI;
public class GemTrigger : MonoBehaviour
{
public SphereCollider Sc;
public MeshRenderer Mr;
public int gemCounter = 0;
private void OnTriggerEnter()
{
gemCounter += 1;
Mr.enabled = false;
Debug.Log("Gem " + gemCounter + " detected");
}
}