Virtual Pet: Help with hunger and happiness mechanic

I’m trying to create a virtual pet game with two different values to worry about, hunger and happiness. If anybody could tell me why hunger and happiness both start at 0 instead of 100 when I play the game it would be greatly appreciated.

I’m brand new to this so let me know if I need to post the complete script or not. Thanks.

My game manager script:

public class GameManager : MonoBehaviour {

    public GameObject happinessText;
    public GameObject hungerText;

    public GameObject nameText;

    public GameObject namePanel;
    public GameObject nameInput;

    public GameObject chao;

    void Update ()
    {
        happinessText.GetComponent<Text>().text = "" + chao.GetComponent<Chao>().happiness;
        hungerText.GetComponent<Text>().text = "" + chao.GetComponent<Chao>().hunger;
        nameText.GetComponent<Text>().text = chao.GetComponent<Chao>().name;
    }

My pet “chao” script:

public class Chao : MonoBehaviour {

    [SerializeField]
    private int _hunger;
    [SerializeField]
    private int _happiness;

void updateStatus()
    {
        if (!PlayerPrefs.HasKey("_hunger"))
        {
            _hunger = 100;
            PlayerPrefs.SetInt("_hunger", _hunger);
        }
        else
        {
            _hunger = PlayerPrefs.GetInt("_hunger");
        }

        if (!PlayerPrefs.HasKey("_happiness"))
        {
            _happiness = 100;
            PlayerPrefs.SetInt("_happiness", _happiness);
        }
        else
        {
            _happiness = PlayerPrefs.GetInt("_happiness");
        }

public int hunger
    {
        get { return _hunger; }
        set { _hunger = value; }
    }

    public int happiness
    {
        get { return _happiness; }
        set { _happiness = value; }
    }

is updateStatus ever getting called?

I believe so.

void Start ()
    {
        //PlayerPrefs.SetString ("then", "5/12/2017 01:20:12");
        updateStatus();
        if (!PlayerPrefs.HasKey("chaoName"))
        {
            PlayerPrefs.SetString("chaoName", "chao");
            _chaoName = PlayerPrefs.GetString("chaoName");
        }

Let me guess, you started the game once and did not set health at that time, but PlayerPrefs generated the String for health, so now, your updatestatus skips what you want and goes to health = playerprefs health, which is still 0?

Maybe so. How would I go about fixing that?

Well, you either delete your registry entries of your game , so your playerprefs are deleted, or you just overwrite health on start with what you need for developing and just remove that part when you are done.

PlayerPrefs.DeleteAll(); will delete all entries for your game.

Thanks so much guys!