Game Development Stack Exchange is a query and reply web site for skilled and impartial recreation builders. It solely takes a minute to enroll.
Anybody can ask a query
Anybody can reply
The greatest solutions are voted up and rise to the highest
Asked
Viewed
16 instances
I would like the assault transfer to chill down after 3 clicks, after which re-enable after time has handed.
I acquired the three clicks cooldown, however I am unable to wrap my head on the opposite half.
utilizing System.Collections.Generic;
utilizing UnityEngine;
public class ASDF : MonoBehaviour
{
[SerializeField] personal float attackCooldown;
personal float subsequentAttackTime;
personal Animator anim;
int counter;
personal float cooldown = 1f;
personal float finalAttackedAt = -9999f;
int delayBeforeCooldownStart;
// Start is known as earlier than the primary body replace
void Start()
{
anim = GetComponentInChildren<Animator>();
}
// Update is known as as soon as per body
void Update()
{
if (Input.GetKeyDown(KeyCode.Mouse0) && (Time.time > subsequentAttackTime))
{
Attack();
Debug.Log("get hit");
counter = counter + 1;
Debug.Log(counter);
}
if (counter >= 3)
{
subsequentAttackTime = Time.time + attackCooldown;
counter = 0;
}
}
personal void Attack()
{
anim.SetTrigger("Attack1");
}
personal void timer()
{
anim.SetBool("reset", false);
}
}
//if (Time.time > finalAttackTime + delayBeforeCooldownStart)
// subsequentAttackTime = Time.time + attackCooldown;
$endgroup$
1
lang-cs