- character colliders stay enabled when the character is unconscious/stunned (prevents getting stuck inside walls when the collider is re-enabled)

- can't climb over obstacles if the contact point is above the center of the character collider
- higher "obstacle climbing velocity"
- limiting collider velocity when dragging another character
This commit is contained in:
Regalis
2016-11-06 18:56:03 +02:00
parent 92985f3ed9
commit de3966ae95
3 changed files with 38 additions and 12 deletions
@@ -51,10 +51,20 @@ namespace Barotrauma
if (character.IsDead || character.IsUnconscious || stunTimer > 0.0f) if (character.IsDead || character.IsUnconscious || stunTimer > 0.0f)
{ {
collider.PhysEnabled = false; collider.FarseerBody.FixedRotation = false;
collider.SetTransform(MainLimb.SimPosition, 0.0f);
if (stunTimer > 0.0f) if (character.IsRemotePlayer)
{
MainLimb.pullJoint.WorldAnchorB = collider.SimPosition;
MainLimb.pullJoint.Enabled = true;
}
else
{
collider.LinearVelocity = (GetLimb(LimbType.Torso).SimPosition - collider.SimPosition) * 60.0f;
collider.SmoothRotate(GetLimb(LimbType.Torso).Rotation);
}
if (stunTimer > 0)
{ {
stunTimer -= deltaTime; stunTimer -= deltaTime;
} }
@@ -57,8 +57,18 @@ namespace Barotrauma
if (character.IsDead || character.IsUnconscious || stunTimer > 0.0f) if (character.IsDead || character.IsUnconscious || stunTimer > 0.0f)
{ {
collider.PhysEnabled = false; collider.FarseerBody.FixedRotation = false;
collider.SetTransform(GetLimb(LimbType.Torso).SimPosition, 0.0f);
if (character.IsRemotePlayer)
{
MainLimb.pullJoint.WorldAnchorB = collider.SimPosition;
MainLimb.pullJoint.Enabled = true;
}
else
{
collider.LinearVelocity = (GetLimb(LimbType.Torso).SimPosition - collider.SimPosition) * 60.0f;
collider.SmoothRotate(GetLimb(LimbType.Torso).Rotation);
}
if (stunTimer > 0) if (stunTimer > 0)
{ {
@@ -87,21 +97,21 @@ namespace Barotrauma
collider.SetTransform(new Vector2( collider.SetTransform(new Vector2(
collider.SimPosition.X, collider.SimPosition.X,
Math.Max(lowestLimb.SimPosition.Y + (collider.radius + collider.height / 2), collider.SimPosition.Y)), Math.Max(lowestLimb.SimPosition.Y + (collider.radius + collider.height / 2), collider.SimPosition.Y)),
0.0f); collider.Rotation);
collider.FarseerBody.Enabled = true; collider.FarseerBody.Enabled = true;
} }
if (swimming) if (swimming)
{ {
collider.FarseerBody.FixedRotation = false; collider.FarseerBody.FixedRotation = false;
} }
else if (!collider.FarseerBody.FixedRotation) else if (!collider.FarseerBody.FixedRotation)
{ {
if (Math.Abs(MathUtils.GetShortestAngle(collider.Rotation, 0.0f)) > 0.001f) if (Math.Abs(MathUtils.GetShortestAngle(collider.Rotation, 0.0f)) > 0.001f)
{ {
//rotate collider back upright //rotate collider back upright
collider.AngularVelocity = MathUtils.GetShortestAngle(collider.Rotation, 0.0f) * 60.0f; collider.AngularVelocity = MathUtils.GetShortestAngle(collider.Rotation, 0.0f) * 10.0f;
collider.FarseerBody.FixedRotation = false; collider.FarseerBody.FixedRotation = false;
} }
else else
@@ -502,7 +512,8 @@ namespace Barotrauma
float colliderBottomY = GetColliderBottom().Y; float colliderBottomY = GetColliderBottom().Y;
//the contact point should be higher than the bottom of the collider //the contact point should be higher than the bottom of the collider
if (((Vector2)handle).Y < colliderBottomY + 0.01f) return; if (((Vector2)handle).Y < colliderBottomY + 0.01f ||
((Vector2)handle).Y > collider.SimPosition.Y) return;
//find the height of the floor below the torso //find the height of the floor below the torso
//(if moving towards towards an obstacle that's low enough to climb over, the torso should be above it) //(if moving towards towards an obstacle that's low enough to climb over, the torso should be above it)
@@ -511,7 +522,7 @@ namespace Barotrauma
if (obstacleY > colliderBottomY) if (obstacleY > colliderBottomY)
{ {
//higher vertical velocity for taller obstacles //higher vertical velocity for taller obstacles
collider.LinearVelocity += Vector2.UnitY * (((Vector2)handle).Y - colliderBottomY + 0.01f) * 10; collider.LinearVelocity += Vector2.UnitY * (((Vector2)handle).Y - colliderBottomY + 0.01f) * 50;
onGround = true; onGround = true;
} }
} }
@@ -891,7 +902,9 @@ namespace Barotrauma
} }
} }
float dist = Vector2.Distance(target.SimPosition, collider.SimPosition);
targetMovement *= MathHelper.Clamp(1.5f - dist, 0.0f, 1.0f);
target.AnimController.IgnorePlatforms = IgnorePlatforms; target.AnimController.IgnorePlatforms = IgnorePlatforms;
if (target.Stun > 0.0f || target.IsDead) if (target.Stun > 0.0f || target.IsDead)
@@ -1133,7 +1133,10 @@ namespace Barotrauma
public Vector2 GetColliderBottom() public Vector2 GetColliderBottom()
{ {
return collider.SimPosition - Vector2.UnitY * (collider.height / 2 + collider.radius); float halfHeight = collider.height / 2 + collider.radius;
return collider.SimPosition +
new Vector2((float)Math.Sin(collider.Rotation), -(float)Math.Cos(collider.Rotation)) * halfHeight;
} }
public Limb FindLowestLimb() public Limb FindLowestLimb()