using UnityEngine;
using System.Collections;
public class PlayerHp
{
public float playerhealth = 100;
public void DamagePlayer(float amount)
{
playerhealth -= amount;
}
}
I have this script attached to my player. I access this script using public PlayerHp PlayerHealth = new PlayerHp(); and then alter the value of playerhealth using PlayerHealth.DamagePlayer(Damage) in another script.
There is another script which accesses the value of playerhealth using PlayerHp health = new PlayerHp(); and then calling health.playerhealth to access its value.
The problem is, when I alter the value of playerhealth in the second script the change is not applied to the third one, how can I solve this issue?
Thanks in Advance.