Jump to content
Unity Insider Forum

Time Bar Funktioniert nicht


Recommended Posts

Hallo, 

ich hab ein Spieler der nach jedem Schuss ein kleinen Cooldown hat ich wollte den Cooldown an einer Progress Bar/ Time Bar anzeigen lassen jedoch geht die Anzeige erst nach unten wenn der Cooldown schon abgelaufen ist.bzw startet viel zu spät

 

für die Progressbar

public class progressbar : MonoBehaviour
{
    public int minimum;
    public int maximum;
    public int current;
    public Image mask;
    public Joystick joystickscript;   
    void Update()
    {
        mask.fillAmount = joystickscript.cooldowntimer; 
    }
    void Getfill()
    {
        float currentOffset = current - minimum;
        float maximumoffset = maximum - minimum;
        float fillAmount = currentOffset / maximumoffset;
    }
    
}

 

Für die den Cooldownr:

public float cooldown = 5;
    public float cooldowntimer;
 void Update()
    {
        
        if (cooldowntimer > 0)
        {
            cooldowntimer -= Time.deltaTime;
        }

        if (cooldowntimer < 0)
        {
            cooldowntimer = 0;
        }
    }
     public void OnPointerUp(PointerEventData eventData)
    {

        if (cooldowntimer == 0)
        {
            playermove.shoot();
              
            cooldowntimer = cooldown;
        }   
    }

Danke im voraus

Link zu diesem Kommentar
Auf anderen Seiten teilen

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Auf dieses Thema antworten...

×   Du hast formatierten Text eingefügt.   Formatierung jetzt entfernen

  Only 75 emoji are allowed.

×   Dein Link wurde automatisch eingebettet.   Einbetten rückgängig machen und als Link darstellen

×   Dein vorheriger Inhalt wurde wiederhergestellt.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Lädt...
×
×
  • Neu erstellen...