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