I have a soda drinking script where if i press U it allows me to only once add 8 to my current health (60%). It works good but when i press U it instantly goes to 68. How can i make it smooth like it counts up 60 61 62 63 64…68???
Here’s the script:
var isReady : boolean = true;
var isPlayed : boolean;
var healthGiven : boolean;
var sodaDrinkAudio : AudioClip;
var playerMovementScript : PlayerMovementScript;
var health : AdvancedHealth;
var sodaHealth : int = 9;
function Update () {
if(Input.GetKeyDown("u") && isReady && !healthGiven && !isPlayed && playerMovementScript.currentGun == gameObject)
{
healthGiven = true;
isPlayed = true;
if(healthGiven && isPlayed)
{
isReady = false;
giveHealthSoda();
audio.PlayOneShot(sodaDrinkAudio);
}
}
}
function giveHealthSoda () {
health.maxHealth += sodaHealth;
}
Do you want it to slowly increase while you hold U, or slowly increase after you click U once?
– dorpelegslowly after i press it once
– inglipX