Attack까지 완성..?
This commit is contained in:
32
Assets/Scripts/PlayerAttack.cs
Normal file
32
Assets/Scripts/PlayerAttack.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user