32 lines
737 B
C#
32 lines
737 B
C#
using System;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class PlayerAttack: MonoBehaviour
|
|
{
|
|
public GameObject attackHitbox;
|
|
private UnicornInputSystem _unicornInput;
|
|
private void Start()
|
|
{
|
|
_unicornInput = UnicornInput.Unicorn;
|
|
_unicornInput.Player.Attack.performed += Attack;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
_unicornInput.Player.Attack.performed -= Attack;
|
|
}
|
|
|
|
private void Attack(InputAction.CallbackContext obj)
|
|
{
|
|
StartCoroutine(OnAttack());
|
|
}
|
|
|
|
private IEnumerator OnAttack()
|
|
{
|
|
attackHitbox.SetActive(true);
|
|
yield return new WaitForSeconds(0.5f);
|
|
attackHitbox.SetActive(false);
|
|
}
|
|
} |