Problem with Auto Save Checkboxes

Discussion and help for Easy Save 3
Post Reply
thrawndev
Posts: 6
Joined: Thu Aug 12, 2021 5:24 pm

Problem with Auto Save Checkboxes

Post by thrawndev »

Hi!

Firstly, let me say im really pleased with ES3!

However im running into an issue that i cant seem to fix myself. I am using the ES3 AutoSave function.

I have a player that has a basic "Player Health" script attached to it to manage current health and to reduce that when damage is taken. IE fall damage.

The problem is, that when i tick the box under the player to save include the Player Heath script, it doesn't hold. So when I enter play mode and then go back to the editor, the health script inst selected.

This is causing the following scenario:

Player starts the game with 10 health points(Max Health) > player saves game with Max Health > player incurs damage so health is reduced to 9 health points > player loads last save, health is correctly displayed as MaxHealth again > player takes the same damage but instead damage is double the amount taken( ao now 8 health points, should be the same as before).

I think this is because ES3 is not recording the Health Script that tracks current health and i cant seem to select the script under Auto Save.

Any idea what im doing wrong or how i can get ES3 to keep track of the current health value?

Code: Select all

public class PlayerHealth : MonoBehaviour
{
    //Health
    public int maxHealth = 10;
    public int currentHealth;
    public HealthBar healthBar;
    public Level2Manager levelManager;

    public GameObject damageIndicator;

    void Start()
    {
        currentHealth = maxHealth;
        healthBar.SetMaxHealth(maxHealth);
    }

    public void TakeDamage(int damage)
    {
        currentHealth -= damage;
        healthBar.SetHealth(currentHealth);
        damageIndicator.SetActive(true);
    }

    public void GiveHealth(int health)
    {
        currentHealth += health;
        healthBar.SetHealth(currentHealth);
    }

    public void Update()
    {
        if(currentHealth > 10)
        {
            currentHealth = maxHealth;
            healthBar.SetMaxHealth(maxHealth);
        }

        if (currentHealth <= 0)
        {
            //levelManager.RestartLevel();
        }
    }
}
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Problem with Auto Save Checkboxes

Post by Joel »

Hi there,

There is an error in your code. In your Start() method you are doing:

Code: Select all

currentHealth = maxHealth;
This will always overwrite the loaded value because it happens after the data has loaded. In this case you would need to manually trigger the Auto Save in order to ensure that it is called after your Start() methods are called (see Triggering Auto Save from Code for more information).

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
thrawndev
Posts: 6
Joined: Thu Aug 12, 2021 5:24 pm

Re: Problem with Auto Save Checkboxes

Post by thrawndev »

Thanks Joel!

Feel a tad stupid i didn't see this!!

Coding is not my strong point!!

However, I am still having an issue selecting the checkboxs in AutoSave not staying selected. I cant seem to load the player health values.

As before, i select the script in the AutoSave menu to save, it selects but when i enter playmode, the script is not selected and the values are not saved.

I can post a video if that helps?
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Problem with Auto Save Checkboxes

Post by Joel »

Hi there,

We've had no other reports of this. Please could you replicate this in a new project using the latest version of Easy Save and private message it to me with instructions?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
thrawndev
Posts: 6
Joined: Thu Aug 12, 2021 5:24 pm

Re: Problem with Auto Save Checkboxes

Post by thrawndev »

Hi Joel

Before i recreate a project to try and recreate the issue, here is a link to a simple video of the issue. It may well be possible i am not doing something right.

https://youtu.be/enyRKhFNlqs

What do you think?
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Problem with Auto Save Checkboxes

Post by Joel »

Hi there,

I'm afraid I'm not able to understand what is happening from a video. If you're able to private message me a basic project which replicates this I'm happy to take a look.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
thrawndev
Posts: 6
Joined: Thu Aug 12, 2021 5:24 pm

Re: Problem with Auto Save Checkboxes

Post by thrawndev »

Hi Joel

Sorry, I really dont have time to recreate a project right now and then try and replicate.

The issue is fairly straightforward though, most likely i am just doing something wrong.

In Autosave, when i tick checkboxes (as seen in the video i linked previously), they do not remain ticked when entering playmode...

Any Ideas?

Oli
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Problem with Auto Save Checkboxes

Post by Joel »

Hi there,

Just to check, are you using the latest version of Easy Save (3.3.2f7)? You can find the version number in Plugins/Easy Save 3/Change Log/.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
thrawndev
Posts: 6
Joined: Thu Aug 12, 2021 5:24 pm

Re: Problem with Auto Save Checkboxes

Post by thrawndev »

Hi Joel

Using 3.3.2f5

Let me update to new version and get back to you whether this fixed the issue or not

Thanks again
Post Reply