Implement player punch and crude damage system

This commit is contained in:
RochesterX
2025-01-17 19:46:17 -05:00
parent 0824f3c99a
commit 7a646ca1ea
10 changed files with 1646 additions and 240 deletions

49
Assets/Scripts/Punch.cs Normal file
View File

@@ -0,0 +1,49 @@
using UnityEngine;
using UnityEngine.InputSystem;
[RequireComponent(typeof(PlayerMovement))]
[RequireComponent(typeof(PlayerInput))]
[RequireComponent(typeof(AnimationPlayer))]
public class Punch : MonoBehaviour
{
public bool cancelable = true;
[SerializeField] private BoxCollider2D hurtbox;
InputActionAsset actions;
private void Start()
{
actions = GetComponent<PlayerInput>().actions;
}
private void Update()
{
if (actions.FindAction("Punch").ReadValue<float>() == 1f)
{
if (!cancelable) return;
GetComponent<AnimationPlayer>().Punch();
DisableCancellation();
}
}
public void EnableHurtbox()
{
hurtbox.enabled = true;
}
public void DisableHurtbox()
{
hurtbox.enabled = false;
}
public void DisableCancellation()
{
cancelable = false;
}
public void EnableCancellation()
{
cancelable = true;
}
}