diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs index 3e0e9c81a..5ffc3bd6f 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs @@ -59,8 +59,11 @@ namespace Barotrauma if (character.IsRemotePlayer) { - MainLimb.PullJointWorldAnchorB = Collider.SimPosition; - MainLimb.PullJointEnabled = true; + if (!SimplePhysicsEnabled) + { + MainLimb.PullJointWorldAnchorB = Collider.SimPosition; + MainLimb.PullJointEnabled = true; + } } else { @@ -127,6 +130,9 @@ namespace Barotrauma UpdateWalkAnim(deltaTime); } + + //don't flip or drag when simply physics is enabled + if (SimplePhysicsEnabled) { return; } if (!character.IsRemotePlayer) { @@ -254,13 +260,19 @@ namespace Barotrauma void UpdateSineAnim(float deltaTime) { - movement = TargetMovement*swimSpeed; - + movement = TargetMovement * swimSpeed; + + Collider.LinearVelocity = Vector2.Lerp(Collider.LinearVelocity, movement, 0.5f); + + //limbs are disabled when simple physics is enabled, no need to move them + if (SimplePhysicsEnabled) { return; } + MainLimb.PullJointEnabled = true; MainLimb.PullJointWorldAnchorB = Collider.SimPosition; if (movement.LengthSquared() < 0.00001f) return; + float movementAngle = MathUtils.VectorToAngle(movement) - MathHelper.PiOver2; if (rotateTowardsMovement) @@ -292,16 +304,21 @@ namespace Barotrauma Vector2 pullPos = Limbs[i].PullJointWorldAnchorA; Limbs[i].body.ApplyForce(movement * Limbs[i].SteerForce * Limbs[i].Mass, pullPos); } - - Collider.LinearVelocity = Vector2.Lerp(Collider.LinearVelocity, movement, 0.5f); - + floorY = Limbs[0].SimPosition.Y; } void UpdateWalkAnim(float deltaTime) { movement = MathUtils.SmoothStep(movement, TargetMovement * walkSpeed, 0.2f); - + + Collider.LinearVelocity = new Vector2( + movement.X, + Collider.LinearVelocity.Y > 0.0f ? Collider.LinearVelocity.Y * 0.5f : Collider.LinearVelocity.Y); + + //limbs are disabled when simple physics is enabled, no need to move them + if (SimplePhysicsEnabled) { return; } + float mainLimbHeight, mainLimbAngle; if (MainLimb.type == LimbType.Torso) { @@ -314,11 +331,7 @@ namespace Barotrauma mainLimbAngle = headAngle; } - MainLimb.body.SmoothRotate(mainLimbAngle * Dir, 50.0f); - - Collider.LinearVelocity = new Vector2( - movement.X, - Collider.LinearVelocity.Y > 0.0f ? Collider.LinearVelocity.Y * 0.5f : Collider.LinearVelocity.Y); + MainLimb.body.SmoothRotate(mainLimbAngle * Dir, 50.0f); MainLimb.MoveToPos(GetColliderBottom() + Vector2.UnitY * mainLimbHeight, 10.0f); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs index 14f4dfe66..0a0e2a3e9 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs @@ -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() diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs index 6767454e9..3023a30a2 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/Ragdoll.cs @@ -715,7 +715,7 @@ namespace Barotrauma float totalMass = 0.0f; foreach (Limb limb in Limbs) { - if (limb.IsSevered) continue; + if (limb.IsSevered || !limb.body.Enabled) continue; centerOfMass += limb.Mass * limb.SimPosition; totalMass += limb.Mass; } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Limb.cs b/Barotrauma/BarotraumaShared/Source/Characters/Limb.cs index 30ce91dbf..80e5acf2e 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Limb.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Limb.cs @@ -176,9 +176,14 @@ namespace Barotrauma return; } + if (Vector2.DistanceSquared(pullJoint.WorldAnchorA, value) > 50.0f * 50.0f) { - string errorMsg = "Attempted to move the anchor of a limb's pull joint extremely far from the limb (" + value + ")\n" + Environment.StackTrace; + Vector2 diff = value - pullJoint.WorldAnchorA; + string errorMsg = "Attempted to move the anchor of a limb's pull joint extremely far from the limb (diff: " + diff + + ", limb enabled: " + body.Enabled + + ", simple physics enabled: " + character.AnimController.SimplePhysicsEnabled + ")\n" + + Environment.StackTrace; DebugConsole.ThrowError(errorMsg); GameAnalyticsManager.AddErrorEventOnce("Limb.SetPullJointAnchor:ExcessiveValue", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg); return;