anim is gooder

This commit is contained in:
ohgushiyuga
2026-07-07 16:06:00 +09:00
parent bb90c969b4
commit b8c7e6edd8
6 changed files with 1579 additions and 497 deletions

View File

@@ -36,7 +36,7 @@ AnimatorStateTransition:
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Roar
m_ConditionEvent: Attack_Roar
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -3278649130132006237}
@@ -47,7 +47,7 @@ AnimatorStateTransition:
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.93661976
m_HasExitTime: 1
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
@@ -91,7 +91,7 @@ AnimatorStateMachine:
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: -7266032778200671909}
m_Position: {x: 270, y: 120, z: 0}
m_Position: {x: 260, y: 120, z: 0}
- serializedVersion: 1
m_State: {fileID: 740941546296395993}
m_Position: {x: 270, y: 30, z: 0}
@@ -278,7 +278,7 @@ AnimatorController:
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
- m_Name: Roar
- m_Name: Attack_Roar
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
@@ -379,6 +379,7 @@ AnimatorState:
m_CycleOffset: 0
m_Transitions:
- {fileID: -4410336713657306521}
- {fileID: 1849398034863935081}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
@@ -422,6 +423,31 @@ AnimatorStateTransition:
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &1849398034863935081
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Attack_Roar
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -3278649130132006237}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.95
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &2209837048349348787
AnimatorState:
serializedVersion: 6
@@ -626,7 +652,7 @@ AnimatorStateTransition:
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.78571427
m_HasExitTime: 1
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
@@ -654,7 +680,7 @@ AnimatorStateTransition:
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.9522293
m_HasExitTime: 1
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1

File diff suppressed because it is too large Load Diff

View File

@@ -161,6 +161,31 @@ MonoBehaviour:
targetOpenXRApiVersion:
required: 0
customRuntimeLoaderName:
--- !u!114 &-7680076135584121790
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 90ae1e8c3c7a542bba339faf2e771c5a, type: 3}
m_Name: AndroidXRSupportFeature Standalone
m_EditorClassIdentifier: Unity.XR.AndroidOpenXR::UnityEngine.XR.OpenXR.Features.Android.AndroidXRSupportFeature
m_enabled: 0
nameUi: Android XR Support
version: 1.0.0
featureIdInternal: com.unity.openxr.feature.androidxr-support
openxrExtensionStrings:
company: Unity Technologies
priority: 0
targetOpenXRApiVersion:
required: 0
customRuntimeLoaderName:
symmetricProjection: 0
optimizeBufferDiscards: 1
multiviewRenderRegionsOptimizationMode: 0
--- !u!114 &-7677771197093365762
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -565,8 +590,18 @@ MonoBehaviour:
features:
- {fileID: 8736661028334727731}
- {fileID: 3598254934845347770}
- {fileID: 7055518550748799546}
- {fileID: -7680076135584121790}
- {fileID: 1170704673688743257}
- {fileID: -1187533949232362847}
- {fileID: -949347770443697596}
- {fileID: -1529727133502117446}
- {fileID: 5153017048313567732}
- {fileID: 265326132771859475}
- {fileID: 2834828863856360103}
- {fileID: -2851827796942056979}
- {fileID: -8128959895479975907}
- {fileID: -1926258647260940646}
- {fileID: 6481653220666705815}
- {fileID: 7393116930172532905}
- {fileID: 744375598501864353}
@@ -887,6 +922,28 @@ MonoBehaviour:
customRuntimeLoaderName:
cacheSize: 1048576
perThreadCacheSize: 51200
--- !u!114 &-1926258647260940646
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6c36843bac48b29469f79baf3c98f9b6, type: 3}
m_Name: AndroidXRHandMeshData Standalone
m_EditorClassIdentifier: Unity.XR.AndroidOpenXR::UnityEngine.XR.OpenXR.Features.Android.AndroidXRHandMeshData
m_enabled: 0
nameUi: 'Android XR: Hand Mesh Data'
version: 0.1.0
featureIdInternal: com.unity.openxr.feature.androidxr-hand-mesh-data
openxrExtensionStrings: XR_ANDROID_hand_mesh
company: Unity Technologies
priority: 0
targetOpenXRApiVersion:
required: 0
customRuntimeLoaderName:
--- !u!114 &-1792293151131426384
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -1216,8 +1273,8 @@ MonoBehaviour:
features:
- {fileID: 7011443450567333355}
- {fileID: -671281728444007487}
- {fileID: -6832857813982530537}
- {fileID: -4559034614451708685}
- {fileID: 6956056911768161135}
- {fileID: 5091991234558418143}
- {fileID: 8980318060753866109}
- {fileID: -6559185765804338520}
- {fileID: -4756202077021157709}
@@ -1228,7 +1285,7 @@ MonoBehaviour:
- {fileID: 348827886137839178}
- {fileID: -7499073031166464939}
- {fileID: 7666556398442971420}
- {fileID: 431653824124869831}
- {fileID: 1118878472687837173}
- {fileID: 3985858319333531581}
- {fileID: -6511185071715886993}
- {fileID: -4363231183632145407}
@@ -1634,7 +1691,7 @@ MonoBehaviour:
nameUi: 'Android XR: AR Anchor'
version: 0.1.0
featureIdInternal: com.unity.openxr.feature.arfoundation-androidxr-anchor
openxrExtensionStrings: XR_ANDROID_trackables XR_ANDROID_device_anchor_persistence
openxrExtensionStrings: XR_ANDROID_trackables
company: Unity Technologies
priority: 0
targetOpenXRApiVersion:
@@ -2330,6 +2387,28 @@ MonoBehaviour:
targetOpenXRApiVersion:
required: 0
customRuntimeLoaderName:
--- !u!114 &7055518550748799546
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 12d3bf61b014a48a2b7564c61da9d7ad, type: 3}
m_Name: AndroidXRPerformanceMetrics Standalone
m_EditorClassIdentifier: Unity.XR.AndroidOpenXR::UnityEngine.XR.OpenXR.Features.Android.AndroidXRPerformanceMetrics
m_enabled: 0
nameUi: Android XR Performance Metrics
version: 0.1.0
featureIdInternal: com.unity.openxr.feature.androidxr-performance-metrics
openxrExtensionStrings: XR_ANDROID_performance_metrics
company: Unity Technologies
priority: 0
targetOpenXRApiVersion:
required: 0
customRuntimeLoaderName:
--- !u!114 &7254928762130921164
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -2581,7 +2660,7 @@ MonoBehaviour:
nameUi: 'Android XR: AR Anchor'
version: 0.1.0
featureIdInternal: com.unity.openxr.feature.arfoundation-androidxr-anchor
openxrExtensionStrings: XR_ANDROID_trackables XR_ANDROID_device_anchor_persistence
openxrExtensionStrings: XR_ANDROID_trackables
company: Unity Technologies
priority: 0
targetOpenXRApiVersion:

View File

@@ -698,9 +698,9 @@ MonoBehaviour:
attackRadius: 10
warningMarkerPrefab: {fileID: 878822567682098337, guid: 23f893a4670a7fc4180013174ddad3be, type: 3}
webPrefab: {fileID: 878822567682098337, guid: 23f893a4670a7fc4180013174ddad3be, type: 3}
chargeSpeed: 12
chargeDuration: 1.5
chargeMinimumDistance: 20
chargeSpeed: 15
chargeDuration: 2
chargeMinimumDistance: 8
chargeCooldownDuration: 4
--- !u!195 &139010308
NavMeshAgent:
@@ -5377,7 +5377,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8806329115733545878, guid: 77e7c27b2c5525e4aa8cc9f99d654486, type: 3}
propertyPath: m_LocalPosition.x
value: 70.97
value: 73
objectReference: {fileID: 0}
- target: {fileID: 8806329115733545878, guid: 77e7c27b2c5525e4aa8cc9f99d654486, type: 3}
propertyPath: m_LocalPosition.y

View File

@@ -11,7 +11,7 @@ public class BossController : MonoBehaviour
[SerializeField] private float maxHp = 500f;
[SerializeField] private float currentHp = 500f;
[SerializeField] public float chaseRange = 15f;
[SerializeField] public float biteRange = 8f;
[SerializeField] public float biteRange = 5f;
[Header("必殺技(天井)設定")]
[Tooltip("天井の待機座標となる空のGameObjectのTransformを指定してください")]
@@ -197,6 +197,21 @@ public class BossController : MonoBehaviour
Destroy(web, duration); // 数秒後に自動消滅
}
}
/// <summary>
/// ★超重要:アニメーターに残ってしまった不要なトリガーをすべて強制消去(リセット)する
/// これを各ステートのExit時に呼ぶことで、アニメーションが固まる・遅れて暴発するバグを根絶します
/// </summary>
public void ResetAllAnimationTriggers()
{
if (Anim == null) return;
Anim.ResetTrigger("Attack_Bite");
Anim.ResetTrigger("Attack_Roar");
Anim.ResetTrigger("ChargeStart");
Anim.ResetTrigger("JumpUp");
Anim.ResetTrigger("Land");
Anim.ResetTrigger("StunStart");
}
#endregion
}

View File

@@ -27,7 +27,11 @@ public class SpiderChaseState : ISpiderState
public SpiderChaseState(BossController owner) => boss = owner;
public void EnterState() => boss.Agent.isStopped = false;
public void ExitState() => boss.Agent.isStopped = true;
public void ExitState()
{
boss.Agent.isStopped = true;
boss.ResetAllAnimationTriggers();
}
public void UpdateState()
{
@@ -55,7 +59,7 @@ public class SpiderChaseState : ISpiderState
}
// ==========================================
// ■ STATE: BITE (完全足止め・めり込み防止版)
// ■ STATE: BITE (完全静止・滑り移動ゼロ修正版)
// ==========================================
public class SpiderBiteState : ISpiderState
{
@@ -66,24 +70,34 @@ public class SpiderBiteState : ISpiderState
public void EnterState()
{
stateTimer = 1.5f;
stateTimer = 1.5f; // 噛みつきアニメーションの時間(環境に合わせて調整してください)
// ★超重要:噛みつきモーションに入った瞬間、移動を「完全強制停止」してめり込みを防ぐ
// 1. 【物理ブレーキ】これまでの移動経路を完全に忘却させ、慣性速度も強制ゼロにする
boss.Agent.ResetPath();
boss.Agent.isStopped = true;
boss.Agent.velocity = Vector3.zero; // 慣性もゼロにする
boss.Agent.velocity = Vector3.zero;
// 2. 【アニメーションブレーキ】直前の走っていた速度Speedを強制的に0リセット
// これをしないと、速度の減衰が遅れて「歩きながら噛み付く」ブレンドモーションになります
boss.Anim.SetFloat("Speed", 0f);
// 3. 噛みつきモーションを発動
boss.Anim.SetTrigger("Attack_Bite");
Debug.Log("🎯 蜘蛛ボス:噛みつき攻撃!(その場に完全固定)");
Debug.Log("🎯 蜘蛛ボス:噛みつき攻撃! 経路を完全消去してその場に固定しました。");
}
public void ExitState()
{
// ステートを出るときに停止ロックを解除する
// 次のステートChaseなどに安全に移行できるよう、ナビゲーションの停止を解除
boss.Agent.isStopped = false;
boss.ResetAllAnimationTriggers();
}
public void UpdateState()
{
// 4. 【徹底防衛】アニメーションの再生中に予期せぬ物理反発や滑りが発生しないよう、毎フレーム速度をゼロに固定
boss.Agent.velocity = Vector3.zero;
stateTimer -= Time.deltaTime;
if (stateTimer <= 0f)
{
@@ -93,6 +107,9 @@ public class SpiderBiteState : ISpiderState
}
}
// ==========================================
// ■ STATE: CHARGE (慣性ブレーキ完全修正版)
// ==========================================
public class SpiderChargeState : ISpiderState
{
private BossController boss;
@@ -105,26 +122,29 @@ public class SpiderChargeState : ISpiderState
public void EnterState()
{
roarTimer = 1.5f; // 溜め(咆哮)時間
roarTimer = 5f; // 溜め(咆哮)時間
chargeTimer = boss.chargeDuration;
isChargingPhase = false;
// ★重要:突進の溜め中は、NavMeshAgentの自動移動を「一時停止」にしてその場に固定する
// ★重要:ナビゲーションを止め、さらに残っている移動速度(慣性)を完全にゼロリセットする
boss.Agent.isStopped = true;
boss.Agent.velocity = Vector3.zero; // これにより滑り込みを100%防止します
boss.ResetChargeCooldown();
// その場に完全静止した状態で、満を持して咆哮アニメーションを再生
boss.Anim.SetTrigger("Attack_Roar");
Debug.Log("🔊 蜘蛛ボス:その場で突進の溜め(咆哮)開始");
Debug.Log("🔊 蜘蛛ボス:遠距離を検知してその場でピタッと完全停止。咆哮(溜め)を開始");
}
public void ExitState()
{
boss.Anim.SetBool("IsCharging", false);
// ★重要:突進ステートを出るときは、スピードと加速を通常のザコ敵・巡回時の値に必ず戻す
boss.Agent.speed = boss.NormalSpeed;
boss.Agent.acceleration = boss.NormalAcceleration;
boss.Agent.isStopped = false;
boss.ResetAllAnimationTriggers();
}
public void UpdateState()
@@ -134,6 +154,9 @@ public class SpiderChargeState : ISpiderState
{
roarTimer -= Time.deltaTime;
// ★安全対策溜め期間中、予期せぬ物理の反発などで1ミリも動かないように速度をゼロに固定し続ける
boss.Agent.velocity = Vector3.zero;
if (boss.Player != null)
{
Vector3 lookDir = (boss.Player.position - boss.transform.position).normalized;
@@ -151,34 +174,31 @@ public class SpiderChargeState : ISpiderState
boss.Anim.SetTrigger("ChargeStart");
boss.Anim.SetBool("IsCharging", true);
// 1. 発射する直線ベクトルを確定
if (boss.Player != null)
{
chargeDirection = (boss.Player.position - boss.transform.position).normalized;
chargeDirection.y = 0;
}
// 2. ★プロの技:ボスの正面方向の「遥か彼方(例: 20m先」に、突進の目的地座標を計算
// 20m先の目的地に向かって、NavMeshAgentによる超高速突進ダッシュを発射
Vector3 targetDestination = boss.transform.position + chargeDirection * 20f;
// 3. ★移動をNavMeshAgentに一任する超高速化
boss.Agent.isStopped = false; // 移動再開
boss.Agent.speed = boss.chargeSpeed; // スピードを全速力14fなど
boss.Agent.acceleration = 120f; // 即座に最高速に達するように加速を爆上げする
boss.Agent.isStopped = false;
boss.Agent.speed = boss.chargeSpeed;
boss.Agent.acceleration = 120f;
// 目的地を設定NavMeshの壁やプレイヤーのCharacterControllerを考慮して自動で進むようになる
boss.Agent.SetDestination(targetDestination);
Debug.Log("🚀 蜘蛛ボス:NavMesh突進ダッシュ発射!");
Debug.Log("🚀 蜘蛛ボス:ロックオン完了。全速力で突進ダッシュ発射!");
}
return;
}
// ─── フェーズ2突進中NavMeshAgentが自動で走っているので、スクリプト側はタイマーを監視するだけ ───
// ─── フェーズ2突進中 ───
chargeTimer -= Time.deltaTime;
// 壁やプレイヤーに激突して完全に急停止したか、または設定時間が経過したら安全に終了
if (chargeTimer <= 0f || boss.Agent.velocity.magnitude < 0.2f && chargeTimer < (boss.chargeDuration - 0.3f))
// 壁やプレイヤーに激突して急停止したか、設定時間が経過したら通常状態へ戻る
if (chargeTimer <= 0f || (boss.Agent.velocity.magnitude < 0.2f && chargeTimer < (boss.chargeDuration - 0.3f)))
{
boss.ChangeState<SpiderChaseState>();
}