Dragging fixes. Instead of setting the anchor positions of the pulljoints directly and transforming them to account for the target being in a different sub, a temporary variable is used to calculate the transformed position. Otherwise the non-transformed intermediate values will cause "trying to move pulljoint extremely far" errors which prevent the value from being set.
This commit is contained in:
@@ -1143,15 +1143,17 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
//only pull with one hand when swimming
|
//only pull with one hand when swimming
|
||||||
if (i < 1 || !inWater)
|
if (i > 0 && inWater) continue;
|
||||||
{
|
|
||||||
Vector2 diff = ConvertUnits.ToSimUnits(targetLimb.WorldPosition - pullLimb.WorldPosition);
|
Vector2 diff = ConvertUnits.ToSimUnits(targetLimb.WorldPosition - pullLimb.WorldPosition);
|
||||||
|
|
||||||
pullLimb.PullJointEnabled = true;
|
pullLimb.PullJointEnabled = true;
|
||||||
targetLimb.PullJointEnabled = true;
|
targetLimb.PullJointEnabled = true;
|
||||||
if (targetLimb.type == LimbType.Torso || targetLimb == target.AnimController.MainLimb)
|
if (targetLimb.type == LimbType.Torso || targetLimb == target.AnimController.MainLimb)
|
||||||
{
|
{
|
||||||
pullLimb.PullJointWorldAnchorB = targetLimb.SimPosition;
|
Vector2 pullLimbAnchor = pullLimb.SimPosition;
|
||||||
|
Vector2 targetAnchor = targetLimb.SimPosition;
|
||||||
|
pullLimbAnchor = targetLimb.SimPosition;
|
||||||
pullLimb.PullJointMaxForce = 5000.0f;
|
pullLimb.PullJointMaxForce = 5000.0f;
|
||||||
targetMovement *= MathHelper.Clamp(Mass / target.Mass, 0.5f, 1.0f);
|
targetMovement *= MathHelper.Clamp(Mass / target.Mass, 0.5f, 1.0f);
|
||||||
|
|
||||||
@@ -1162,29 +1164,31 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Vector2 shoulderPos = LimbJoints[2].WorldAnchorA;
|
Vector2 shoulderPos = LimbJoints[2].WorldAnchorA;
|
||||||
Vector2 dragDir = inWater ? Vector2.Normalize(targetLimb.SimPosition - shoulderPos) : Vector2.UnitY;
|
Vector2 dragDir = inWater ? Vector2.Normalize(targetLimb.SimPosition - shoulderPos) : Vector2.UnitY;
|
||||||
targetLimb.PullJointWorldAnchorB = shoulderPos - dragDir * ConvertUnits.ToSimUnits(a + b);
|
targetAnchor = shoulderPos - dragDir * ConvertUnits.ToSimUnits(a + b);
|
||||||
targetLimb.PullJointMaxForce = 200.0f;
|
targetLimb.PullJointMaxForce = 200.0f;
|
||||||
|
|
||||||
if (target.Submarine != character.Submarine)
|
if (target.Submarine != character.Submarine)
|
||||||
{
|
{
|
||||||
if (character.Submarine == null)
|
if (character.Submarine == null)
|
||||||
{
|
{
|
||||||
pullLimb.PullJointWorldAnchorB += target.Submarine.SimPosition;
|
pullLimbAnchor += target.Submarine.SimPosition;
|
||||||
targetLimb.PullJointWorldAnchorB -= target.Submarine.SimPosition;
|
targetAnchor -= target.Submarine.SimPosition;
|
||||||
}
|
}
|
||||||
else if (target.Submarine == null)
|
else if (target.Submarine == null)
|
||||||
{
|
{
|
||||||
pullLimb.PullJointWorldAnchorB -= character.Submarine.SimPosition;
|
pullLimbAnchor -= character.Submarine.SimPosition;
|
||||||
targetLimb.PullJointWorldAnchorB += character.Submarine.SimPosition;
|
targetAnchor += character.Submarine.SimPosition;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pullLimb.PullJointWorldAnchorB -= target.Submarine.SimPosition;
|
pullLimbAnchor -= target.Submarine.SimPosition;
|
||||||
pullLimb.PullJointWorldAnchorB += character.Submarine.SimPosition;
|
pullLimbAnchor += character.Submarine.SimPosition;
|
||||||
targetLimb.PullJointWorldAnchorB -= character.Submarine.SimPosition;
|
targetAnchor -= character.Submarine.SimPosition;
|
||||||
targetLimb.PullJointWorldAnchorB += target.Submarine.SimPosition;
|
targetAnchor += target.Submarine.SimPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pullLimb.PullJointWorldAnchorB = pullLimbAnchor;
|
||||||
|
targetLimb.PullJointWorldAnchorB = targetAnchor;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1197,7 +1201,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
target.AnimController.movement = -diff;
|
target.AnimController.movement = -diff;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
float dist = Vector2.Distance(target.SimPosition, Collider.SimPosition);
|
float dist = Vector2.Distance(target.SimPosition, Collider.SimPosition);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user