I’ll make this short and clear. I got two scripts and I want to lower a number from one script to another.
Script #1 :
var healthBarDisplay : float = 1;
Script #2 :
var damage : float = 0.3f;
var Distance : float;
var attackRange : float = 1.0f;
var playerHealth : PlayerGUI;
function Awake()
{
playerHealth = GameObject.FindWithTag("Player").GetComponent(PlayerGUI);
}
function Update()
{
if(Distance < attackRange)
{
Attack();
}
}
function Attack()
{
animation.Play("Punching");
playerHealth.healthBarDisplay -= damage;
}
This is not the whole script, only a part of it, the rest has nothing to do with what Im looking for.
Now, when the distance is lower then the attack range the healthBarDisplay from script 1 goes down too fast, because it’s being lowered in the update function , which updates every frame.
How do I make it so it lowers only once per second ? Adding time.deltatime doesn’t work the way I want it to.
Thank you, I hope I was clear enough.