@@ -10,17 +10,18 @@ public class VRInputPunch : MonoBehaviour
|
||||
[SerializeField] private XRNode controllerNode = XRNode.RightHand;
|
||||
[SerializeField] private VRInputPoseDetector poseDetector;
|
||||
|
||||
// 攻撃設定
|
||||
[Header("攻撃(パンチ)設定")]
|
||||
[SerializeField] private float minPunchSpeed = 2.0f; // パンチとして判定する最低速度 (m/s)
|
||||
[SerializeField] private float damageMultiplier = 10.0f; // ダメージ倍率
|
||||
[SerializeField] private float hapticAmplitude = 0.5f; // 通常ヒットの振動の強さ
|
||||
[SerializeField] private float hapticDuration = 0.1f; // 通常ヒットの振動の長さ
|
||||
|
||||
// パリィ設定
|
||||
[Header("パリィ設定")]
|
||||
[SerializeField] private float minParrySpeed = 1.0f; // パリィできるパンチとして判定する最低速度 (m/s)
|
||||
[SerializeField] private float parryStunDuration = 3.0f; // スタン時間(秒)
|
||||
[SerializeField] private float parryHapticAmplitude = 0.9f; // パリィ成功時の振動の強さ
|
||||
[SerializeField] private float parryHapticDuration = 0.25f; // パリィ成功時の振動の長さ
|
||||
// ─────────────────────────────────────────
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -52,29 +53,35 @@ public class VRInputPunch : MonoBehaviour
|
||||
Vector3 velocity = velocityAction.action.ReadValue<Vector3>();
|
||||
float speed = velocity.magnitude;
|
||||
|
||||
// パリィ判定
|
||||
//【パリィ判定】当たったオブジェクトが敵の拳だった場合
|
||||
if (other.CompareTag("EnemyFist"))
|
||||
{
|
||||
Debug.Log($"[パリィチェック] 敵の拳と接触。プレイヤーの手の速度: {speed:F2} m/s / 構え状態: {poseDetector.IsPosing}");
|
||||
Debug.Log($"🛡️ [パリィチェック] 敵の拳と接触。プレイヤーの手の速度: {speed:F2} m/s / 構え状態: {poseDetector.IsPosing}");
|
||||
|
||||
// 条件:構え状態(IsPosing)である、もしくは、弾くための速度が一定以上出ている場合
|
||||
if (poseDetector.IsPosing || speed >= minParrySpeed)
|
||||
{
|
||||
// 敵の親オブジェクトからEnemyAIスクリプトを検索
|
||||
EnemyAI enemyAI = other.GetComponentInParent<EnemyAI>();
|
||||
if (enemyAI != null)
|
||||
{
|
||||
// 敵の攻撃コンボを強制中断し、スタン状態にする
|
||||
enemyAI.TriggerParryStun(parryStunDuration);
|
||||
|
||||
// パリィ成功用の強力な振動をプレイヤーに返す
|
||||
TriggerHaptics(parryHapticAmplitude, parryHapticDuration);
|
||||
|
||||
Debug.Log($"ジャストパリィ成功! 敵の体勢を崩しました。スタン時間: {parryStunDuration}秒");
|
||||
return;
|
||||
Debug.Log($"🛡️ 【ジャストパリィ成功!】 敵の体勢を崩しました。スタン時間: {parryStunDuration}秒");
|
||||
return; // パリィが成立した場合は以降のパンチ処理は行わない
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("ガード(または速度不足):敵の攻撃は防いだが、弾き返せなかった。");
|
||||
Debug.Log("🧱 ガード(または速度不足):敵の攻撃は防いだが、弾き返せなかった。");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// ────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
// パンチ攻撃の処理
|
||||
@@ -124,7 +131,7 @@ public class VRInputPunch : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 引数に応じて指定された強さと長さでコントローラーを振動させる
|
||||
/// 引数に応じて指定された強さと長さでコントローラーを振動させる
|
||||
private void TriggerHaptics(float amplitude, float duration)
|
||||
{
|
||||
UnityEngine.XR.InputDevice device = InputDevices.GetDeviceAtXRNode(controllerNode);
|
||||
|
||||
Reference in New Issue
Block a user