Search Unity

Image.Fillamount not working?

Discussion in 'Scripting' started by MrZeker, Jun 22, 2019.

  1. MrZeker

    MrZeker

    Joined:
    Nov 23, 2018
    Posts:
    227
    Hello im trying to make a visual Cooldown, but the command in the unity Api is not working.

    This sets the counter cooldown. (which works, what doesn't work is the visual part)
    Code (csharp):
    1.  
    2.      if (Time.time > PlayerNextCounter)
    3.         {
    4.                 PlayerNextCounter = Time.time + PlayerCounterCD;
    5.                 PlayerCounterIMG.fillAmount = 1;
    6.                 PlayerCounterIsInCD = true;
    7. }
    8.  
    This is in update()
    Code (csharp):
    1.  
    2.         if(PlayerCounterIsInCD == true)
    3.         {
    4.             PlayerCounterIMG.fillAmount -= 1.0f / PlayerCounterCD * Time.deltaTime;
    5.         }
    6.  
    I followed the example, yet it is not working. The counterimg is a image of type Filled in radial 360.

    Any ideas what is wrong here?
     
  2. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    Looks like the formula is wrong.It should be something like

    Code (CSharp):
    1. fillAmout = (Time.time - cooldownStartTime) / cooldownDuration
    2.