here is my attack code
using System;
using System.Collections;
using StarterAssets;
using System.Collections.Generic;
using UnityEngine;
public class playercombat : MonoBehaviour
{
public float delay = 0.3f;
private bool attackBlocked;
public Animator animator;
private ThirdPersonController myLight;
// Update is called once per frame
void Update()
{
myLight = GetComponent<ThirdPersonController>();
if (Input.GetMouseButtonDown(0))
{
Attack();
}
}
private void Attack()
{
if (attackBlocked)
return;
animator.SetTrigger("Attack");
attackBlocked = true;
StartCoroutine(DelayAttack());
}
private IEnumerator DelayAttack()
{
yield return new WaitForSeconds(delay);
attackBlocked = false;
}
}