Recreation Improvement Stack Change is a query and reply website for skilled and impartial sport builders. It solely takes a minute to enroll.
Anyone can ask a query
Anyone can reply
The very best solutions are voted up and rise to the highest
Requested
Seen
3 occasions
I would like the assault transfer to chill down after 3 clicks, after which re-enable after time has handed.
I bought 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] non-public float attackCooldown;
non-public float nextAttackTime;
non-public Animator anim;
int counter;
non-public float cooldown = 1f;
non-public float lastAttackedAt = -9999f;
int delayBeforeCooldownStart;
// Begin is known as earlier than the primary body replace
void Begin()
{
anim = GetComponentInChildren<Animator>();
}
// Replace is known as as soon as per body
void Replace()
{
if (Enter.GetKeyDown(KeyCode.Mouse0) && (Time.time > nextAttackTime))
{
Assault();
Debug.Log("get hit");
counter = counter + 1;
Debug.Log(counter);
}
if (counter >= 3)
{
nextAttackTime = Time.time + attackCooldown;
counter = 0;
}
}
non-public void Assault()
{
anim.SetTrigger("Attack1");
}
non-public void timer()
{
anim.SetBool("reset", false);
}
}
//if (Time.time > lastAttackTime + delayBeforeCooldownStart)
// nextAttackTime = Time.time + attackCooldown;
$endgroup$
1
lang-cs