WIP fixes to ragdoll simple physics mode (see #895). When simple physics is enabled, only the collider of the character moves and all the limbs and joints are disabled. This caused "attempted to move pulljoint anchor extremely far" errors, because the game still attempted to move the limbs to the collider via pull joints. TODO: do more testing to make sure simple physics doesn't cause other physics errors, fix dragging in simple physics mode.

This commit is contained in:
Joonas Rikkonen
2018-11-09 14:13:49 +02:00
parent 083d88a64f
commit a85b496f23
4 changed files with 54 additions and 23 deletions
@@ -516,17 +516,30 @@ namespace Barotrauma
void UpdateStandingSimple()
{
movement = MathUtils.SmoothStep(movement, TargetMovement, movementLerp);
if (inWater && movement.LengthSquared() > 0.00001f)
{
movement = Vector2.Normalize(movement);
}
if (Math.Abs(movement.X)<0.005f)
if (Math.Abs(movement.X) < 0.005f)
{
movement.X = 0.0f;
}
if (InWater)
{
if (inWater && movement.LengthSquared() > 0.00001f)
{
movement = Vector2.Normalize(movement);
}
movement = MathUtils.SmoothStep(movement, TargetMovement, movementLerp);
Collider.LinearVelocity = Vector2.Lerp(Collider.LinearVelocity, movement * swimSpeed, movementLerp);
}
else
{
movement = MathUtils.SmoothStep(movement, TargetMovement * walkSpeed, movementLerp);
if (onGround && (!character.IsRemotePlayer || GameMain.Server != null))
{
Collider.LinearVelocity = new Vector2(
movement.X,
Collider.LinearVelocity.Y > 0.0f ? Collider.LinearVelocity.Y * 0.5f : Collider.LinearVelocity.Y);
}
}
}
private void ClimbOverObstacles()