Files
RatStabber/Assets/C# Scripts/UI overlay/AttackCooldown.cs
Iazubi 0a4d0e9c86 Organization of Game Files
Created folder for C# files, player, and enemy so it's a little cleaner...
2024-10-23 17:28:44 -07:00

20 lines
615 B
C#

using UnityEngine;
public class AttackCooldown : MonoBehaviour
{
Teo player;
UnityEngine.UI.Image bar;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
player = GameObject.FindGameObjectWithTag("Player").GetComponent<Teo>();
bar = GetComponent<UnityEngine.UI.Image>();
}
// Update is called once per frame
void Update()
{
GetComponent<RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Mathf.Max(0, 100-100*(Time.fixedTime-player.lastAttackTime)/player.attackCooldownSeconds));
}
}