0

New! Save questions or solutions and arrange your favourite content material.
Learn extra.

$begingroup$

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;

zeus christ is a brand new contributor to this web site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

$endgroup$

1

You should log in to reply this query.

Browse different questions tagged .