Merge pull request #1 from ProtoSharkk/attackCooldown

Attack cooldown indicator
This commit is contained in:
ProtoSharkk
2024-10-21 20:59:42 -07:00
committed by GitHub

View File

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