Hello everyone, for the cooldown of the skills in my game, Im creating UI icons that shows the chosen skill and the cooldown time so you can use it again.
What Im trying to do is quite simple:
Step 1: The skill blue circle is full, meaning that the skill is charged and ready to use. (See first circle in the image).
Step 2: After using the skill the circle gets empty. (Second circle in the image).
Step 3: The circle starts to fill again, meaning that the skill was used but will be ready to use when the circle is full. The cycle starts again.
But the problem is, after emptying the circle (Step 2), my current script cant fill correctly, it stays empty forever, like the second circle in the image. Script:
public JumpPlayer jPlayer;
public Image coolDownImage;
float cooldownT;
bool isCooldown;
// Use this for initialization
void Start () {
cooldownT = jPlayer.coolDown;
}
// Update is called once per frame
void Update () {
if (jPlayer.coolDownIcon == true) {
coolDownImage.fillAmount = 0;
coolDownImage.fillAmount += 1 / cooldownT * Time.deltaTime;
print(coolDownImage.fillAmount);
if (coolDownImage.fillAmount >= 1) {
coolDownImage.fillAmount = 1;
jPlayer.coolDownIcon = false;
}
}
}
}
Printing the fillamount shows that it sits between 0.0004-0.0005 forever. If I do it in a way that the circle starts empty, after shooting it goes full and make its way to 0 again, it works, but I cant figure how to implement the 3 steps shown above, I thought this script would work but I guess there are some mathematical problems there :s
Thanks in advance!