Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void LateUpdate()
- {
- int curBaseAnimHash = GetCurAnim();
- if (curBaseAnimHash == impactHash)
- {
- float flinchRemaining = 0.0f;
- float flinchTotalTime = 0.0f;
- ai.GetVariable(NpcVars.FlinchRemaining, out flinchRemaining);
- ai.GetVariable(NpcVars.FlinchTotalTime, out flinchTotalTime);
- if (MathManager.IsNearZero(flinchRemaining)) { jiggleBone.localRotation = jiggleBoneRot; }
- else
- {
- // First, do a proper, actual spring equation (even if we're poking in garbage magical tweak params instead of actual mass/etc)
- float jiggleAngle = Mathf.Exp(-sproingDampening * (flinchTotalTime - flinchRemaining)) * sproingAngle * ((Mathf.Cos((flinchTotalTime - flinchRemaining) * sproingFactor * Mathf.PI + Mathf.PI) + 1.0f) * 0.5f);
- // Now just taper the fucker. That way it doesn't give a shit. Underdampen it to hell and back. We still staple on a nice taper, so it "just works" and you can make it pretty.
- float taperFactor = (flinchTotalTime - flinchRemaining) / flinchTotalTime;
- taperFactor *= taperFactor;
- taperFactor = 1.0f - taperFactor;
- jiggleAngle *= taperFactor;
- // Then, apply the tapered angle. Tadaaaaa!
- jiggleBone.localRotation = jiggleBoneRot * Quaternion.AngleAxis(jiggleAngle, jiggleAxis);
- }
- }
- else if (curBaseAnimHash == launchHash)
- {
- float flinchRemaining = 0.0f;
- float flinchTotalTime = 0.0f;
- ai.GetVariable(NpcVars.FlinchRemaining, out flinchRemaining);
- ai.GetVariable(NpcVars.FlinchTotalTime, out flinchTotalTime);
- if (MathManager.IsNearZero(flinchRemaining)) { spinBone.localRotation = spinBoneRot; }
- else
- {
- float totalSpinRads = Mathf.Round(flinchTotalTime * launchSpinsPerSec) * 360.0f;
- float spinTval = (flinchTotalTime - flinchRemaining) / flinchTotalTime;
- // Then, apply the tapered angle. Tadaaaaa!
- spinBone.localRotation = spinBoneRot * Quaternion.AngleAxis(spinTval * totalSpinRads, spinAxis);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment