parry and health bar pt1
This commit is contained in:
@@ -6,6 +6,9 @@ public class Block : MonoBehaviour
|
||||
{
|
||||
public bool blocking = false;
|
||||
private InputActionAsset actions;
|
||||
private float blockPressTime = 0f;
|
||||
private float parryThreshold = 0.2f;
|
||||
private bool isParrying = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -15,16 +18,40 @@ public class Block : MonoBehaviour
|
||||
private void Update()
|
||||
{
|
||||
InputAction blockAction = actions.FindAction("Block");
|
||||
|
||||
if (blockAction.ReadValue<float>() == 1f)
|
||||
{
|
||||
if (!blocking)
|
||||
{
|
||||
blockPressTime = Time.time;
|
||||
}
|
||||
blocking = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (blocking)
|
||||
{
|
||||
float pressDuration = Time.time - blockPressTime;
|
||||
if (pressDuration <= parryThreshold)
|
||||
{
|
||||
Parry();
|
||||
}
|
||||
else
|
||||
{
|
||||
isParrying = false;
|
||||
}
|
||||
}
|
||||
blocking = false;
|
||||
}
|
||||
|
||||
GetComponent<AnimationPlayer>().block = blocking;
|
||||
}
|
||||
|
||||
private void Parry()
|
||||
{
|
||||
isParrying = true;
|
||||
}
|
||||
|
||||
public bool IsParrying()
|
||||
{
|
||||
return isParrying;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user