If the distance is excessively large when forcing the collider of a dead character to follow the body, the collider is teleported instead of moving it by setting the velocity. + More physics error logging
This commit is contained in:
@@ -64,8 +64,16 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Collider.LinearVelocity = (MainLimb.SimPosition - Collider.SimPosition) * 60.0f;
|
Vector2 diff = (MainLimb.SimPosition - Collider.SimPosition);
|
||||||
Collider.SmoothRotate(MainLimb.Rotation);
|
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)
|
if (character.IsDead && deathAnimTimer < deathAnimDuration)
|
||||||
|
|||||||
@@ -94,14 +94,22 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
levitatingCollider = false;
|
levitatingCollider = false;
|
||||||
Collider.FarseerBody.FixedRotation = 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.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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1243,6 +1251,24 @@ namespace Barotrauma
|
|||||||
Vector2 currItemPos = (character.SelectedItems[0] == item) ?
|
Vector2 currItemPos = (character.SelectedItems[0] == item) ?
|
||||||
rightHand.pullJoint.WorldAnchorA - transformedHandlePos[0] :
|
rightHand.pullJoint.WorldAnchorA - transformedHandlePos[0] :
|
||||||
leftHand.pullJoint.WorldAnchorA - transformedHandlePos[1];
|
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(currItemPos, itemAngle);
|
||||||
|
|
||||||
//item.SetTransform(MathUtils.SmoothStep(item.body.SimPosition, transformedHoldPos + bodyVelocity, 0.5f), itemAngle);
|
//item.SetTransform(MathUtils.SmoothStep(item.body.SimPosition, transformedHoldPos + bodyVelocity, 0.5f), itemAngle);
|
||||||
|
|||||||
@@ -202,7 +202,6 @@ namespace Barotrauma.Items.Components
|
|||||||
foreach (Item contained in Inventory.Items)
|
foreach (Item contained in Inventory.Items)
|
||||||
{
|
{
|
||||||
if (contained == null) continue;
|
if (contained == null) continue;
|
||||||
|
|
||||||
if (contained.body != null)
|
if (contained.body != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -211,9 +210,10 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
DebugConsole.Log("SetTransformIgnoreContacts threw an exception in SetContainedItemPositions ("+e.Message+")\n"+e.StackTrace);
|
||||||
DebugConsole.ThrowError("SetTransformIgnoreContacts threw an exception in SetContainedItemPositions", e);
|
GameAnalyticsManager.AddErrorEventOnce("ItemContainer.SetContainedItemPositions.InvalidPosition:"+contained.Name,
|
||||||
#endif
|
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
||||||
|
"SetTransformIgnoreContacts threw an exception in SetContainedItemPositions (" + e.Message + ")\n" + e.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user