I'm building a 2D platformer with multiple scenes and a lot of collectibles for every scene (coins, health pickups and so forth).
Every time an item is picked up it is deactivated and a bool is set to "pickedup". Here is my coin script. This script is on every coin.
Code: Select all
[SerializeField] private int coinsToGive;
private ScoreManager scoreManager;
private AudioManager audioManager;
public bool isPickedUp = false;
// Use this for initialization
void Start ()
{
scoreManager = FindObjectOfType<ScoreManager>();
audioManager = FindObjectOfType<AudioManager>();
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player")
{
scoreManager.AddCoin(coinsToGive);
audioManager.PlayCoin();
isPickedUp = true;
gameObject.SetActive(false);
}
}
Any idea on how to achieve this with Easy Save? I don't know where to start. A code snippet as example would be really nice. The rest of the data saves nicely (high score, score, player position etc). Needless to say this part is crucial to avoid cheating by the player.
Thanks in advance