Enemy hit-reacts: React/Stagger anim tiers off Health-drop edges (the Rukhanka-safe flinch)
SwordCombat React (1.4x, 0.3s pulse) + Stagger (1.2x, 0.55s) as Any-State states on AC_EnemyTopDown via EnemyRigTools.WireEnemyHitReacts; driven by EnemyAnimationDriveSystem's cache (now Pos/Hp/ReactUntil/Heavy) off replicated Health drops. Windup-honesty gate: light reacts require !IsAttacking (a sub-poise hit never visually cancels a live windup); the heavy tier tracks the server's B2 poise break (stagger threshold 50 = finisher staggers, light flinches at the locked tuning). Knobs: HitReactSeconds (0=off) / HitStaggerSeconds / HitReactStaggerDamage. Replaces the review-cut positional vibrate (Rukhanka inverse-fold no-op). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -42,13 +42,24 @@ namespace ProjectM.Client
|
||||
static readonly FastAnimatorParameter k_Speed = new FastAnimatorParameter("Speed");
|
||||
static readonly FastAnimatorParameter k_IsAttacking = new FastAnimatorParameter("IsAttacking");
|
||||
static readonly FastAnimatorParameter k_IsDead = new FastAnimatorParameter("IsDead"); // B3: the controller's Death state existed but was never driven
|
||||
static readonly FastAnimatorParameter k_IsHit = new FastAnimatorParameter("IsHit"); // 07-21 hit-react (G5): pulsed off replicated Health-drop edges
|
||||
static readonly FastAnimatorParameter k_IsHitHeavy = new FastAnimatorParameter("IsHitHeavy"); // heavy tier -> HitStagger (aligns with the server's B2 poise break)
|
||||
|
||||
// prevPos cache (per Husk Entity). Pruned every frame (a vanished Husk = a server-authoritative death).
|
||||
NativeParallelHashMap<Entity, float3> _prevPos;
|
||||
/// <summary>07-21: per-Husk anim cache -- position (velocity derivation), Health (the hit-react damage
|
||||
/// edge), and the active flinch pulse. Pruned every frame (a vanished Husk = a server-authoritative death).</summary>
|
||||
struct EnemyAnimCache
|
||||
{
|
||||
public float3 Pos;
|
||||
public float Hp;
|
||||
public float ReactUntil; // wall-clock ElapsedTime the flinch pulse ends (0 = none)
|
||||
public bool Heavy; // this pulse is the stagger tier
|
||||
}
|
||||
|
||||
NativeParallelHashMap<Entity, EnemyAnimCache> _prevPos;
|
||||
|
||||
protected override void OnCreate()
|
||||
{
|
||||
_prevPos = new NativeParallelHashMap<Entity, float3>(64, Allocator.Persistent);
|
||||
_prevPos = new NativeParallelHashMap<Entity, EnemyAnimCache>(64, Allocator.Persistent);
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
@@ -65,6 +76,12 @@ namespace ProjectM.Client
|
||||
var job = new EnemyDriveJob
|
||||
{
|
||||
moveX = k_MoveX, moveZ = k_MoveZ, speed = k_Speed, isAttacking = k_IsAttacking, isDead = k_IsDead,
|
||||
isHit = k_IsHit, isHitHeavy = k_IsHitHeavy,
|
||||
// 07-21 hit-react knobs (read main-thread, passed by value -- never FeelConfig inside Burst)
|
||||
el = (float)SystemAPI.Time.ElapsedTime,
|
||||
reactSeconds = math.max(0f, FeelConfig.HitReactSeconds),
|
||||
staggerSeconds = math.max(0f, FeelConfig.HitStaggerSeconds),
|
||||
staggerDamage = math.max(1f, FeelConfig.HitReactStaggerDamage),
|
||||
dt = dt,
|
||||
prevPos = _prevPos,
|
||||
seen = seen,
|
||||
@@ -92,11 +109,12 @@ namespace ProjectM.Client
|
||||
[WithAll(typeof(EnemyTag))]
|
||||
partial struct EnemyDriveJob : IJobEntity
|
||||
{
|
||||
public FastAnimatorParameter moveX, moveZ, speed, isAttacking, isDead;
|
||||
public FastAnimatorParameter moveX, moveZ, speed, isAttacking, isDead, isHit, isHitHeavy;
|
||||
public float el, reactSeconds, staggerSeconds, staggerDamage; // 07-21 hit-react (reactSeconds 0 = off)
|
||||
[Unity.Collections.ReadOnly] public ComponentLookup<IsLunging> isLunging; // A7: a lunge has no AttackWindup; OR it in so the boss/Charger attack anim plays during the committed lunge
|
||||
|
||||
public float dt;
|
||||
public NativeParallelHashMap<Entity, float3> prevPos;
|
||||
public NativeParallelHashMap<Entity, EnemyAnimCache> prevPos;
|
||||
public NativeParallelHashSet<Entity> seen;
|
||||
|
||||
void Execute(
|
||||
@@ -111,9 +129,23 @@ namespace ProjectM.Client
|
||||
seen.Add(e);
|
||||
float3 cur = xform.Position;
|
||||
float3 vel = float3.zero;
|
||||
var cache = new EnemyAnimCache { Pos = cur, Hp = health.Current };
|
||||
if (prevPos.TryGetValue(e, out var prev))
|
||||
vel = (cur - prev) / dt;
|
||||
prevPos[e] = cur;
|
||||
{
|
||||
vel = (cur - prev.Pos) / dt;
|
||||
cache.ReactUntil = prev.ReactUntil;
|
||||
cache.Heavy = prev.Heavy;
|
||||
// 07-21 hit-react (G5): a replicated Health DROP on a living Husk = the flinch edge. The heavy
|
||||
// tier (>= staggerDamage, e.g. the finisher) plays the stagger -- aligned with the server's B2
|
||||
// poise break, so the anim never claims an interrupt the sim didn't make.
|
||||
float drop = prev.Hp - health.Current;
|
||||
if (drop > 0.01f && health.Current > 0f && reactSeconds > 0f)
|
||||
{
|
||||
cache.Heavy = drop >= staggerDamage;
|
||||
cache.ReactUntil = el + (cache.Heavy ? staggerSeconds : reactSeconds);
|
||||
}
|
||||
}
|
||||
prevPos[e] = cache;
|
||||
|
||||
float2 facing = AnimParamMath.PlanarForward(xform.Rotation);
|
||||
float3 p = AnimParamMath.LocomotionParams(vel, facing, stats.MoveSpeed);
|
||||
@@ -130,6 +162,10 @@ namespace ProjectM.Client
|
||||
if (a.HasParameter(speed)) a.SetParameterValue(speed, p.z);
|
||||
if (a.HasParameter(isAttacking)) a.SetParameterValue(isAttacking, attacking);
|
||||
if (a.HasParameter(isDead)) a.SetParameterValue(isDead, dead);
|
||||
// 07-21 hit-react pulse (a corpse never flinches; the controller adds the windup-honesty gate).
|
||||
bool hitActive = !dead && cache.ReactUntil > 0f && el < cache.ReactUntil;
|
||||
if (a.HasParameter(isHit)) a.SetParameterValue(isHit, hitActive);
|
||||
if (a.HasParameter(isHitHeavy)) a.SetParameterValue(isHitHeavy, hitActive && cache.Heavy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +163,15 @@ namespace ProjectM.Client
|
||||
/// <summary>Camera hold frames when the melee FINISHER lands (07-20 G5 impact ladder; light hits use HitStopMaxFrames).</summary>
|
||||
public static int FinisherHoldFrames;
|
||||
|
||||
// ---- 07-21 enemy hit-reacts (G5; the Rukhanka-safe flinch that replaced the cut vibrate) ----
|
||||
/// <summary>Seconds the light flinch pulse holds (0 = hit-reacts OFF).</summary>
|
||||
public static float HitReactSeconds;
|
||||
/// <summary>Seconds the heavy stagger pulse holds.</summary>
|
||||
public static float HitStaggerSeconds;
|
||||
/// <summary>Health drop at/above which the react upgrades to the STAGGER tier (keep aligned with the
|
||||
/// server's B2 poise math: the finisher should stagger, a light hit should not).</summary>
|
||||
public static float HitReactStaggerDamage;
|
||||
|
||||
|
||||
/// <summary>Master gate for gamepad rumble (no-op on KBM).</summary>
|
||||
public static bool RumbleEnabled;
|
||||
@@ -290,6 +299,9 @@ namespace ProjectM.Client
|
||||
MeleeArcIntensity = 0.8f; // 07-21 HEAVY LOCK: the weapon is the read, the arc recedes further
|
||||
MeleeArcBubbles = 6;
|
||||
FinisherHoldFrames = 7; // 07-21 HEAVY LOCK: a fatter finisher beat (~117ms, still under the 8-frame ladder cap)
|
||||
HitReactSeconds = 0.3f; // 07-21: light flinch pulse (clip plays at 1.4x -> the peak lands inside it)
|
||||
HitStaggerSeconds = 0.55f; // heavy stagger pulse
|
||||
HitReactStaggerDamage = 50f; // finisher (63 seeded) staggers, light (42) flinches -- tracks B2 poise
|
||||
|
||||
|
||||
RumbleEnabled = true;
|
||||
|
||||
Reference in New Issue
Block a user