Hello, I’m making a mobile game and I don’t know how to save the amount of money I got.
I want when I exit the game, the game will be saved and when I join again I have the same amount of money I had before.
(like Temple run, Subway surf etc…)
Thanks.
THE COIN SCRIPT
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CoinsScript : MonoBehaviour {
private Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent<Animator>();
}
private void OnTriggerEnter(Collider other)
{
if(other.name == "Player")
{
other.GetComponent<PlayerMotor>().coins++;
anim.SetTrigger("Collected");
Destroy(gameObject);
}
}
}