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();
}
}
}