diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs index 0d67b09f8..2878f3715 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/FishAnimController.cs @@ -64,8 +64,16 @@ namespace Barotrauma } else { - Collider.LinearVelocity = (MainLimb.SimPosition - Collider.SimPosition) * 60.0f; - Collider.SmoothRotate(MainLimb.Rotation); + Vector2 diff = (MainLimb.SimPosition - Collider.SimPosition); + if (diff.LengthSquared() > 10.0f * 10.0f) + { + Collider.SetTransform(MainLimb.SimPosition, MainLimb.Rotation); + } + else + { + Collider.LinearVelocity = diff * 60.0f; + Collider.SmoothRotate(MainLimb.Rotation); + } } if (character.IsDead && deathAnimTimer < deathAnimDuration) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs index a83e895c0..5d2842fbb 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs @@ -94,14 +94,22 @@ namespace Barotrauma { levitatingCollider = false; Collider.FarseerBody.FixedRotation = false; - - if (Math.Abs(Collider.Rotation-GetLimb(LimbType.Torso).Rotation)>Math.PI*0.6f) + + if (Math.Abs(Collider.Rotation - GetLimb(LimbType.Torso).Rotation) > Math.PI * 0.6f) { Collider.SetTransform(Collider.SimPosition, MathHelper.WrapAngle(Collider.Rotation + (float)Math.PI)); } - Collider.SmoothRotate(GetLimb(LimbType.Torso).Rotation); - Collider.LinearVelocity = (GetLimb(LimbType.Waist).SimPosition - Collider.SimPosition) * 20.0f; - + + Vector2 diff = GetLimb(LimbType.Waist).SimPosition - Collider.SimPosition; + if (diff.LengthSquared() > 10.0f * 10.0f) + { + Collider.SetTransform(GetLimb(LimbType.Waist).SimPosition, GetLimb(LimbType.Torso).Rotation); + } + else + { + Collider.LinearVelocity = diff * 20.0f; + Collider.SmoothRotate(GetLimb(LimbType.Torso).Rotation); + } return; } @@ -1243,6 +1251,24 @@ namespace Barotrauma Vector2 currItemPos = (character.SelectedItems[0] == item) ? rightHand.pullJoint.WorldAnchorA - transformedHandlePos[0] : leftHand.pullJoint.WorldAnchorA - transformedHandlePos[1]; + + if (!MathUtils.IsValid(currItemPos)) + { + string errorMsg = "Attempted to move the item \"" + item + "\" to an invalid position in HumanidAnimController.HoldItem: " + + currItemPos + ", rightHandPos: " + rightHand.pullJoint.WorldAnchorA + ", leftHandPos: " + leftHand.pullJoint.WorldAnchorA + + ", handlePos[0]: " + handlePos[0] + ", handlePos[1]: " + handlePos[1] + + ", transformedHandlePos[0]: " + transformedHandlePos[0] + ", transformedHandlePos[1]:" + transformedHandlePos[1] + + ", item pos: " + item.SimPosition + ", itemAngle: " + itemAngle + + ", collider pos: " + character.SimPosition; + DebugConsole.Log(errorMsg); + GameAnalyticsManager.AddErrorEventOnce( + "HumanoidAnimController.HoldItem:InvalidPos:" + character.Name + item.Name, + GameAnalyticsSDK.Net.EGAErrorSeverity.Error, + errorMsg); + + return; + } + item.SetTransform(currItemPos, itemAngle); //item.SetTransform(MathUtils.SmoothStep(item.body.SimPosition, transformedHoldPos + bodyVelocity, 0.5f), itemAngle); diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemContainer.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemContainer.cs index 416082a19..456315b20 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemContainer.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemContainer.cs @@ -202,7 +202,6 @@ namespace Barotrauma.Items.Components foreach (Item contained in Inventory.Items) { if (contained == null) continue; - if (contained.body != null) { try @@ -211,9 +210,10 @@ namespace Barotrauma.Items.Components } catch (Exception e) { -#if DEBUG - DebugConsole.ThrowError("SetTransformIgnoreContacts threw an exception in SetContainedItemPositions", e); -#endif + DebugConsole.Log("SetTransformIgnoreContacts threw an exception in SetContainedItemPositions ("+e.Message+")\n"+e.StackTrace); + GameAnalyticsManager.AddErrorEventOnce("ItemContainer.SetContainedItemPositions.InvalidPosition:"+contained.Name, + GameAnalyticsSDK.Net.EGAErrorSeverity.Error, + "SetTransformIgnoreContacts threw an exception in SetContainedItemPositions (" + e.Message + ")\n" + e.StackTrace); } }