I’m not that great with coding but I need help with the scoring in my game. Its a simple sandwich stacking 2D game where the players have to collect food ingredients onto the piece of bread. I’m using an edge collider for scoring but the problem is that an ingredient that is already on the sandwich will give the player more points if it moves around and touched the trigger on the collider again. I don’t want this. How do I add in my coding “if and ingredient falls on the bread slice then the player receives only one point.” Here is what my coding is so far.
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour {
public GUIText scoreText;
public int foodValue;
private int score;
// Use this for initialization
void Start () {
score = 0;
UpdateScore ();
}
void OnTriggerEnter2D () {
score += foodValue;
UpdateScore ();
}
void UpdateScore () {
scoreText.text = "Score:
" + score;
}
}