So if i save my scene then kill an enemy, after killing them i press L to load to go before the fight, when it loads the enemy is laying down as dead but is still alive and moves to attack me while laying down.
its definitely something to do with the Health script based on the error unity is passing me:
Parameter 'load' does not exist.
UnityEngine.Animator:SetTrigger (string)
RPG.Core.Health:RestoreState (object) (at Assets/Scripts/Core/Health.cs:67)
RPG.Saving.SaveableEntity:RestoreState (object) (at Assets/Scripts/Saving/SaveableEntity.cs:39)
RPG.Saving.SavingSystem:RestoreState (System.Collections.Generic.Dictionary`2<string, object>) (at Assets/Scripts/Saving/SavingSystem.cs:85)
RPG.Saving.SavingSystem:Load (string) (at Assets/Scripts/Saving/SavingSystem.cs:35)
RPG.SceneManagement.SavingWrapper:Load () (at Assets/Scripts/SceneManagement/SavingWrapper.cs:42)
RPG.SceneManagement.SavingWrapper:Update () (at Assets/Scripts/SceneManagement/SavingWrapper.cs:30)
namespace RPG.Core
{
public class Health : MonoBehaviour, ISaveable
{
[SerializeField] private float healthPoints = 100f;
private Animator animator;
private ActionScheduler actionScheduler;
private bool isDead = false;
private void Awake()
{
actionScheduler = GetComponent<ActionScheduler>();
animator = GetComponent<Animator>();
}
public void TakeDamage(float damage)
{
//bounded health between 0 and 100
healthPoints = Mathf.Max(healthPoints - damage, 0);
if(healthPoints == 0)
{
Die();
}
}
private void Die()
{
if (isDead) return;
isDead = true;
animator.SetTrigger("Die");
actionScheduler.CancelCurrentAction();
}
public bool IsDead()
{
return isDead;
}
public object CaptureState()
{
return healthPoints;
}
public void RestoreState(object state)
{
healthPoints = (float)state;
if (healthPoints > 0)
{
isDead = false;
GetComponent<Animator>().SetTrigger("load");
}
else Die();
}
}
}