(9b19bda7d) Workaround to characters' arms occasionally spinning when standing in place, don't offset limping characters' feet when not moving (the heavy leaning forwards looks unnatural), added a comment

This commit is contained in:
Joonas Rikkonen
2019-05-03 13:57:42 +03:00
parent 9121c878f5
commit 872eeb70ce
5 changed files with 73 additions and 220 deletions
@@ -579,7 +579,7 @@ namespace Barotrauma
if (limpAmount > 0.0f)
{
//make the footpos oscillate when limping
footMid += ((float)Math.Max(Math.Abs(walkPosX) * limpAmount, 0.0f) * 0.3f);
footMid += (Math.Max(Math.Abs(walkPosX) * limpAmount, 0.0f) * Math.Min(Math.Abs(TargetMovement.X), 0.3f));
}
movement = overrideTargetMovement == Vector2.Zero ?
@@ -788,13 +788,19 @@ namespace Barotrauma
//get the upper arm to point downwards
var arm = GetLimb(armType);
arm.body.SmoothRotate(MathHelper.Clamp(-arm.body.AngularVelocity, -0.1f, 0.1f), arm.Mass * 10.0f);
if (Math.Abs(arm.body.AngularVelocity) < 10.0f)
{
arm.body.SmoothRotate(MathHelper.Clamp(-arm.body.AngularVelocity, -0.1f, 0.1f), arm.Mass * 10.0f);
}
//get the elbow to a neutral rotation
LimbJoint elbow =
if (Math.Abs(hand.body.AngularVelocity) < 10.0f)
{
LimbJoint elbow =
GetJointBetweenLimbs(armType, hand.type) ??
GetJointBetweenLimbs(armType, foreArmType);
hand.body.ApplyTorque(-elbow.JointAngle * hand.Mass * 10.0f);
hand.body.ApplyTorque(MathHelper.Clamp(-elbow.JointAngle, -MathHelper.PiOver2, MathHelper.PiOver2) * hand.Mass * 10.0f);
}
}
}
}
@@ -692,6 +692,10 @@ namespace Barotrauma
character.AddDamage(impactPos, new List<Affliction>() { AfflictionPrefab.InternalDamage.Instantiate((impact - ImpactTolerance) * 10.0f) }, 0.0f, true);
strongestImpact = Math.Max(strongestImpact, impact - ImpactTolerance);
character.ApplyStatusEffects(ActionType.OnImpact, 1.0f);
//briefly disable impact damage
//otherwise the character will take damage multiple times when for example falling,
//because we use the velocity of the collider to determine the impact
//(i.e. the character would take damage until the collider hits the floor and stops)
character.DisableImpactDamageTimer = 0.25f;
}
}