Good morning,
After we made the change to our progression system, the player’s health gets replenished through portals. I looked up and down my script and I can’t figure out why. My player Prefab Does have a dedicated unique identifier.
I honestly do not know where else to look
namespace RPG.Attributes
{
public class Health : MonoBehaviour ,ISaveable
{
[SerializeField]float maxHealth;
bool isDead= false;
public bool IsDead{get{return isDead;}}
void Start()
{
// baseStats= GetComponent<BaseStats>();
maxHealth= GetComponent<BaseStats>().GetStatFromBaseStats(Stats.Stats.Health);
}
public float GetHealthForDisplay()
{
return (maxHealth/GetComponent<BaseStats>().GetStatFromBaseStats(Stats.Stats.Health)) * 100;
}
public void TakeDamage(GameObject instigator,float damage)
{
maxHealth= Mathf.Max(maxHealth-damage, 0);
// print(maxHealth);
if(maxHealth<= 0)
{
TriggerDeath(instigator);
}
}
private void TriggerDeath(GameObject theOnceWhoDidTheKilling)
{
if(isDead) return;
GetComponent<Animator>().SetTrigger("dying");
GetComponent<CapsuleCollider>().enabled= false;
GetComponent<ActionScheduler>().CancelCurrentAction();
RewardExperience(theOnceWhoDidTheKilling);
isDead = true;
}
void RewardExperience(GameObject killer)
{
if (killer == null) return;
float experienceToReward = GetComponent<BaseStats>().GetStatFromBaseStats(Stats.Stats.ExperienceReward);
PlayerExperience playerExperience= killer.GetComponent<PlayerExperience>();
if(playerExperience == null) return;
playerExperience.GainExperience(experienceToReward);
}
public object CaptureState()
{
return maxHealth;
}
public void RestoreState(object state)
{
maxHealth = (float) state;
if (maxHealth <= 0)
{
TriggerDeath(null);
}
}
}
}
Any advice?