Hello,
I would like to know why my function isn’t working properly even though I am doing it correctly well!
From PlayerStats class:
public void DecreaseStat(float value, float value1)
{
value -= value1;
}
From PlayerController class:
private void Shoot()
{
if(Input.GetKeyDown(KeyCode.F))
{
if(PlayerStats.Instance.HasEnergy(_playerProjectileEnergyCost))
{
/*_playerEnergy -= 25;
_playerEnergy = Mathf.Clamp(_playerEnergy, 0.0f, _playerMaxEnergy);*/
PlayerStats.Instance.DecreaseStat(_playerEnergy,_playerProjectileEnergyCost);
UpdateEnergyUI();
GameObject projectile = (GameObject) Instantiate(_projectile, transform.position, Quaternion.identity);
//projectile.transform.SetParent(transform, false);
}
}
}
It isn’t decreasing my energy at all, but if I have my DecreaseStat function on the same class and I call it normally. It actually works. Is there any explanation for it ? I would love to know, I even wondered if it could be my Singleton.
Thank you very much for the attention.