Creating a Farming RPG in Unity - Part 12: Sleeping and Saving

Creating a Farming RPG (like Harvest Moon) in Unity — Part 12: Sleeping and Saving

This article is a part of the series:
Creating a Farming RPG (like Harvest Moon) in Unity

Ever wanted to create a game like Harvest Moon in Unity? Check out Part 12 of our guide here, where we go through how to implement the player's sleep feature, as well as saving game data to both JSON and binary files. You can also find Part 11 of our guide here, where we went through how to save our farmland's data.

To view this content, you must be a member of Terresquall's Patreon at $5 or more
Already our Patron? Login to access this content.

There are 4 comments:

  1. When I sleep twice, my cabbage state changes to Harvestable, and I get an array index error when I go from home to farm.

  2. After completing this tutorial when I launch I get a unity pause with the issue –

    *NullReferenceException: Object reference not set to an instance of an object*
    In reference to this line – List landData = LandManager.farmData.Item1;

    Then when I un-pause unity it runs fine.

    1. Hi Corey, for Unity pausing on error, it’s because you enabled Error Pause in the Unity Editor: https://answers.unity.com/questions/737305/unity-pausing-when-runtime-error-occurs.html

      As for the NullReferenceException, whenever you get this, what you want to look at are at areas where you have a chain of full-stops (.), because what it is saying is that one of the objects you are referring to in the chain is null.

      In your case, it can mean that LandManager.farmData is null, or LandManager.farmData.Item1 is null. You can check if either item is null by doing a print before the line:

      print(LandManager.farmData);
      print(LandManager.farmData.Item1);

      Once you find which is the null item, ensure that it is filled and the error should go away.

Leave a Reply to Terence Cancel reply

Your email address will not be published. Required fields are marked *

Note: You can use Markdown to format your comments.

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

I agree to these terms.

This site uses Akismet to reduce spam. Learn how your comment data is processed.